diff --git a/snippets/sdk/python-sdk-2-quickstart.mdx b/snippets/sdk/python-sdk-2-quickstart.mdx new file mode 100644 index 000000000..adabf64de --- /dev/null +++ b/snippets/sdk/python-sdk-2-quickstart.mdx @@ -0,0 +1,30 @@ +```python +from metadata.sdk import Tables, configure +from metadata.generated.schema.api.data.createTable import CreateTableRequest +from metadata.generated.schema.entity.data.table import Column, DataType + +# The host must end with /api +configure(host="http://localhost:8585/api", jwt_token="your-jwt-token") + +# Create +table = Tables.create( + CreateTableRequest( + name="customers", + databaseSchema="mysql-prod.analytics.public", + columns=[Column(name="id", dataType=DataType.BIGINT)], + ) +) + +print(table.fullyQualifiedName.root) + +# Update +table.description = "Customer master table" +table = Tables.update(table) + +# Delete +Tables.delete(table.id) +``` + +Fields such as `name`, `id`, and `fullyQualifiedName` are wrapper objects. Use `.root` to get the plain value, for example `table.fullyQualifiedName.root`. + +Call `configure()` with no arguments to read `OPENMETADATA_HOST` and `OPENMETADATA_JWT_TOKEN` from your environment. diff --git a/snippets/sdk/python-sdk-choice.mdx b/snippets/sdk/python-sdk-choice.mdx new file mode 100644 index 000000000..aaeda684e --- /dev/null +++ b/snippets/sdk/python-sdk-choice.mdx @@ -0,0 +1,37 @@ +## Which Python SDK Should I Use? + +The `openmetadata-ingestion` package contains two Python clients. Both talk to the same OpenMetadata API. + +| | Original client | SDK 2.0 | +|---|---|---| +| Import | `metadata.ingestion.ometa.ometa_api.OpenMetadata` | `metadata.sdk` | +| Setup | Build an `OpenMetadataConnection` and pass it to `OpenMetadata(...)` | Call `configure(host=..., jwt_token=...)` once | +| Style | Generic methods that take an entity type, such as `metadata.get_by_name(entity=Table, fqn=...)` | One class per entity, such as `Tables.retrieve_by_name(fqn)` | +| Available since | Every release | OpenMetadata 1.10.0 | + +For new scripts and jobs, use SDK 2.0. It needs less setup and reads more simply. Use the original client when you need an operation that SDK 2.0 doesn't offer yet, or when you maintain existing code that already uses it. + +### Using Both Clients in One Script + +Both ship in the same package, so one script can use both. Set up each one separately: call `configure()` for SDK 2.0 and build an `OpenMetadata` client for the original client. + +### Migrating an Existing Job + +Change one call at a time: + +| Original client | SDK 2.0 | +|---|---| +| `metadata.create_or_update(data=request)` | `Tables.create(request)` | +| `metadata.get_by_id(entity=Table, entity_id=id)` | `Tables.retrieve(id)` | +| `metadata.get_by_name(entity=Table, fqn=fqn)` | `Tables.retrieve_by_name(fqn)` | +| `metadata.list_all_entities(entity=Table)` | `Tables.list_all()` | +| `metadata.list_entities(entity=Table, params={...})` | `Tables.list(filters={...})` | +| `metadata.delete(entity=Table, entity_id=id)` | `Tables.delete(id)` | + +`Tables.create(request)` also updates an existing table, the same as `create_or_update`. + +Three details differ from what you might expect: + +- In `configure(host=...)`, include `/api` at the end of the URL, the same as `hostPort` in the original client. +- When you list entities, pass query filters as `filters={"databaseSchema": "service.database.schema"}` and read the results from `.entities`. +- With the original client, set `authProvider="openmetadata"` when you authenticate with a JWT token. SDK 2.0 doesn't need an `authProvider`. diff --git a/v1.13.x/api-reference.mdx b/v1.13.x/api-reference.mdx index f435f009e..be353ffe2 100644 --- a/v1.13.x/api-reference.mdx +++ b/v1.13.x/api-reference.mdx @@ -86,10 +86,14 @@ metadata = OpenMetadata(server_config) # List tables tables = metadata.list_all_entities(entity=Table) for table in tables: - print(f"{table.fullyQualifiedName}: {table.description}") + print(f"{table.fullyQualifiedName.root}: {getattr(table.description, 'root', table.description)}") ``` ```java Java +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.models.ListParams; + // Configure connection OpenMetadataConfig config = OpenMetadataConfig.builder() .serverUrl("https://your-company.open-metadata.org/api") @@ -99,9 +103,8 @@ OpenMetadataConfig config = OpenMetadataConfig.builder() OpenMetadataClient client = new OpenMetadataClient(config); // List tables -TablesApi tablesApi = client.buildClient(TablesApi.class); -TableList tables = tablesApi.listTables(null, 10, null, null, null); -for (Table table : tables.getData()) { +var tables = client.tables().list(new ListParams().setLimit(10)); +for (var table : tables.getData()) { System.out.println(table.getFullyQualifiedName()); } ``` diff --git a/v1.13.x/api-reference/authentication.mdx b/v1.13.x/api-reference/authentication.mdx index 3ad38abbd..8b37874a0 100644 --- a/v1.13.x/api-reference/authentication.mdx +++ b/v1.13.x/api-reference/authentication.mdx @@ -81,21 +81,17 @@ tables = metadata.list_all_entities(entity=Table) ``` ```java Token Example -import org.openmetadata.client.gateway.OpenMetadata; -import org.openmetadata.schema.services.connections.metadata.OpenMetadataConnection; -import org.openmetadata.schema.security.client.OpenMetadataJWTClientConfig; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; // Configure with JWT token -OpenMetadataConnection config = new OpenMetadataConnection(); -config.setHostPort("https://your-company.open-metadata.org/api"); -config.setAuthProvider(AuthProvider.OPENMETADATA); - -OpenMetadataJWTClientConfig jwtConfig = new OpenMetadataJWTClientConfig(); -jwtConfig.setJwtToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."); -config.setSecurityConfig(jwtConfig); +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("https://your-company.open-metadata.org/api") + .accessToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...") + .build(); // Create authenticated client -OpenMetadata client = new OpenMetadata(config); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ```bash Token Example diff --git a/v1.13.x/api-reference/data-assets/api-collections/create.mdx b/v1.13.x/api-reference/data-assets/api-collections/create.mdx index f0abc3fef..7a97e534c 100644 --- a/v1.13.x/api-reference/data-assets/api-collections/create.mdx +++ b/v1.13.x/api-reference/data-assets/api-collections/create.mdx @@ -16,11 +16,11 @@ Create a new API collection within an API service. - Fully qualified name of the parent APIService (e.g., `sample_api_service`). + Fully qualified name of the parent APIService, for example `sample_api_service`. - Base URL for the API collection (e.g., `https://petstore3.swagger.io/#/pet`). + Base URL for the API collection, for example `https://petstore3.swagger.io/#/pet`. @@ -40,7 +40,7 @@ Create a new API collection within an API service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -49,8 +49,8 @@ Create a new API collection within an API service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -62,11 +62,11 @@ Create a new API collection within an API service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -94,19 +94,23 @@ request = CreateAPICollectionRequest( ) api_collection = APICollections.create(request) -print(f"Created: {api_collection.fullyQualifiedName}") +print(f"Created: {api_collection.fullyQualifiedName.root}") ``` ```java POST /v1/apiCollections -import static org.openmetadata.sdk.fluent.APICollections.*; - -// Create using builder pattern -var apiCollection = APICollections.builder() - .name("pet") - .service("sample_api_service") - .endpointURL("https://petstore3.swagger.io/#/pet") - .description("Pet-related API endpoints") - .create(); +import java.net.URI; +import org.openmetadata.schema.api.data.CreateAPICollection; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. + +CreateAPICollection request = new CreateAPICollection() + .withName("pet") + .withService("sample_api_service") + .withEndpointURL(URI.create("https://petstore3.swagger.io/#/pet")) + .withDescription("Pet-related API endpoints"); + +APICollection apiCollection = client.apiCollections().create(request); ``` ```bash POST /v1/apiCollections @@ -204,7 +208,7 @@ Returns the created API collection object with all specified properties and syst - Type of API service (e.g., Rest). + Type of API service, for example Rest. @@ -216,7 +220,7 @@ Returns the created API collection object with all specified properties and syst - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -238,11 +242,11 @@ Returns the created API collection object with all specified properties and syst - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/api-collections/delete.mdx b/v1.13.x/api-reference/data-assets/api-collections/delete.mdx index b70156430..66238adf7 100644 --- a/v1.13.x/api-reference/data-assets/api-collections/delete.mdx +++ b/v1.13.x/api-reference/data-assets/api-collections/delete.mdx @@ -28,7 +28,7 @@ Delete an API collection by ID or fully qualified name. Supports soft delete (de Use `DELETE /v1/apiCollections/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the API collection (e.g., `sample_api_service.pet`). + Fully qualified name of the API collection, for example `sample_api_service.pet`. @@ -66,36 +66,40 @@ APICollections.delete( hard_delete=True ) -# Delete by name -APICollections.delete_by_name("sample_api_service.pet") +# Delete by name (look up the ID first) +entity = APICollections.retrieve_by_name("sample_api_service.pet") +APICollections.delete(entity.id) # Delete by name with options -APICollections.delete_by_name( - "sample_api_service.pet", - hard_delete=True -) +entity = APICollections.retrieve_by_name("sample_api_service.pet") +APICollections.delete(entity.id, hard_delete=True) # Restore a soft-deleted API collection APICollections.restore("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") ``` ```java DELETE /v1/apiCollections/{id} -import static org.openmetadata.sdk.fluent.APICollections.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -APICollections.delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b").execute(); +client.apiCollections().delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); // Hard delete -APICollections.delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") - .hardDelete() - .execute(); +client.apiCollections().delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b", Map.of("hardDelete", "true")); // Delete by name -APICollections.deleteByName("sample_api_service.pet") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/apiCollections/name/sample_api_service.pet", + null, + Void.class +); // Restore -APICollections.restore("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +client.apiCollections().restore("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); ``` ```bash DELETE /v1/apiCollections/{id} diff --git a/v1.13.x/api-reference/data-assets/api-collections/list.mdx b/v1.13.x/api-reference/data-assets/api-collections/list.mdx index 3407abaaf..07f3cc8e1 100644 --- a/v1.13.x/api-reference/data-assets/api-collections/list.mdx +++ b/v1.13.x/api-reference/data-assets/api-collections/list.mdx @@ -47,48 +47,53 @@ configure( # List first page collections = APICollections.list(limit=50) -for ac in collections.data: - print(f"{ac.fullyQualifiedName}") +for ac in collections.entities: + print(f"{ac.fullyQualifiedName.root}") # List all with auto-pagination for ac in APICollections.list_all(): - print(f"{ac.fullyQualifiedName}") + print(f"{ac.fullyQualifiedName.root}") # Filter by service collections = APICollections.list( - service="sample_api_service", - fields=["owners", "tags", "domain"], + filters={"service": "sample_api_service"}, + fields=["owners", "tags", "domains"], limit=50 ) -for ac in collections.data: - print(f"{ac.fullyQualifiedName}") +for ac in collections.entities: + print(f"{ac.fullyQualifiedName.root}") if ac.owners: - print(f" Owners: {[o.name for o in ac.owners]}") + print(f" Owners: {[o.name for o in ac.owners.root]}") if ac.tags: - print(f" Tags: {[t.tagFQN for t in ac.tags]}") + print(f" Tags: {[t.tagFQN.root for t in ac.tags]}") ``` ```java GET /v1/apiCollections -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. // List first page -var result = APICollections.list() - .limit(50) - .execute(); +ListResponse firstPage = client.apiCollections().list( + new ListParams().setLimit(50) +); -for (var ac : result.getData()) { +for (APICollection ac : firstPage.getData()) { System.out.println(ac.getFullyQualifiedName()); } // Filter by service with fields -var result = APICollections.list() - .service("sample_api_service") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var ac : result.getData()) { +ListResponse filtered = client.apiCollections().list( + new ListParams() + .setService("sample_api_service") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (APICollection ac : filtered.getData()) { System.out.println(ac.getFullyQualifiedName()); } ``` @@ -180,7 +185,7 @@ Returns a paginated list of API collection objects. By default, only basic field - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v1.13.x/api-reference/data-assets/api-collections/retrieve.mdx b/v1.13.x/api-reference/data-assets/api-collections/retrieve.mdx index f0e976e4f..6315ccb3d 100644 --- a/v1.13.x/api-reference/data-assets/api-collections/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/api-collections/retrieve.mdx @@ -16,7 +16,7 @@ Get a single API collection by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single API collection by its unique ID or fully qualified name. Use `GET /v1/apiCollections/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the API collection (e.g., `sample_api_service.pet`). + Fully qualified name of the API collection, for example `sample_api_service.pet`. @@ -51,7 +51,7 @@ configure( # Get by ID ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") -print(f"{ac.fullyQualifiedName}: {ac.description}") +print(f"{ac.fullyQualifiedName.root}: {ac.name.root}") # Get by ID with fields ac = APICollections.retrieve( @@ -65,31 +65,33 @@ ac = APICollections.retrieve_by_name("sample_api_service.pet") # Get by name with fields ac = APICollections.retrieve_by_name( "sample_api_service.pet", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/apiCollections/{id} -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. // Get by ID -var ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +APICollection ac = client.apiCollections().get("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); // Get by ID with fields -var ac = APICollections.retrieve( +APICollection acWithFields = client.apiCollections().get( "0f7ee81c-8163-4097-8adb-45c3d6c7b14b", "owners,tags" ); // Get by fully qualified name -var ac = APICollections.retrieveByName( +APICollection acByName = client.apiCollections().getByName( "sample_api_service.pet" ); // Get by name with fields -var ac = APICollections.retrieveByName( +APICollection acByNameWithFields = client.apiCollections().getByName( "sample_api_service.pet", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -194,7 +196,7 @@ Returns an API collection object with all requested fields populated. - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v1.13.x/api-reference/data-assets/api-collections/update.mdx b/v1.13.x/api-reference/data-assets/api-collections/update.mdx index 38735efd1..65160f2a0 100644 --- a/v1.13.x/api-reference/data-assets/api-collections/update.mdx +++ b/v1.13.x/api-reference/data-assets/api-collections/update.mdx @@ -20,7 +20,7 @@ Update an API collection's properties using JSON Merge Patch. You can update by Use `PATCH /v1/apiCollections/name/{fqn}` to update by fully qualified name. - Fully qualified name of the API collection (e.g., `sample_api_service.pet`). + Fully qualified name of the API collection, for example `sample_api_service.pet`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -62,17 +62,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -94,16 +94,18 @@ ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") ac.description = "Updated: Pet-related API endpoints for the Petstore service" updated = APICollections.update(ac) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/apiCollections/{id} -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +APICollection ac = client.apiCollections().get("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); ac.setDescription("Updated: Pet-related API endpoints for the Petstore service"); -var updated = APICollections.update(ac); +APICollection updated = client.apiCollections().update("0f7ee81c-8163-4097-8adb-45c3d6c7b14b", ac); ``` ```bash PATCH /v1/apiCollections/{id} diff --git a/v1.13.x/api-reference/data-assets/api-collections/versions.mdx b/v1.13.x/api-reference/data-assets/api-collections/versions.mdx index 9fc8af7e1..7f880d3ce 100644 --- a/v1.13.x/api-reference/data-assets/api-collections/versions.mdx +++ b/v1.13.x/api-reference/data-assets/api-collections/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/apiCollections/{id}/versions/{version}` to retrieve a specific vers - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/apiCollections/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import APICollections @@ -40,28 +42,30 @@ configure( # List all versions versions = APICollections.get_versions("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version ac_v1 = APICollections.get_specific_version( "0f7ee81c-8163-4097-8adb-45c3d6c7b14b", "0.1" ) -print(f"Original description: {ac_v1.description}") +print(f"Original description: {ac_v1.description.root if ac_v1.description else None}") ``` ```java GET /v1/apiCollections/{id}/versions -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.schema.entity.data.APICollection; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = APICollections.getVersions("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +EntityHistory history = client.apiCollections().getVersionList("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = APICollections.getSpecificVersion( +APICollection v1 = client.apiCollections().getVersion( "0f7ee81c-8163-4097-8adb-45c3d6c7b14b", 0.1 ); diff --git a/v1.13.x/api-reference/data-assets/api-endpoints/create.mdx b/v1.13.x/api-reference/data-assets/api-endpoints/create.mdx index cc5043d76..372802543 100644 --- a/v1.13.x/api-reference/data-assets/api-endpoints/create.mdx +++ b/v1.13.x/api-reference/data-assets/api-endpoints/create.mdx @@ -16,11 +16,11 @@ Create a new API endpoint within an API collection. - Fully qualified name of the parent APICollection (e.g., `sample_api_service.pet`). + Fully qualified name of the parent APICollection, for example `sample_api_service.pet`. - URL for the API endpoint (e.g., `https://petstore3.swagger.io/#/pet/addPet`). + URL for the API endpoint, for example `https://petstore3.swagger.io/#/pet/addPet`. @@ -32,7 +32,7 @@ Create a new API endpoint within an API collection. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -44,7 +44,7 @@ Create a new API endpoint within an API collection. - Data type of the field (e.g., `INT`, `STRING`, `OBJECT`). + Data type of the field, for example `INT`, `STRING`, `OBJECT`. @@ -60,7 +60,7 @@ Create a new API endpoint within an API collection. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -100,7 +100,7 @@ Create a new API endpoint within an API collection. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -109,8 +109,8 @@ Create a new API endpoint within an API collection. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -122,11 +122,11 @@ Create a new API endpoint within an API collection. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -162,21 +162,26 @@ request = CreateAPIEndpointRequest( ) endpoint = APIEndpoints.create(request) -print(f"Created: {endpoint.fullyQualifiedName}") +print(f"Created: {endpoint.fullyQualifiedName.root}") ``` ```java POST /v1/apiEndpoints -import static org.openmetadata.sdk.fluent.APIEndpoints.*; - -// Create using builder pattern -var endpoint = APIEndpoints.builder() - .name("addPet") - .displayName("Add Pet") - .apiCollection("sample_api_service.pet") - .description("Add a new pet to the store") - .endpointURL("https://petstore3.swagger.io/#/pet/addPet") - .requestMethod("POST") - .create(); +import java.net.URI; +import org.openmetadata.schema.api.data.CreateAPIEndpoint; +import org.openmetadata.schema.entity.data.APIEndpoint; +import org.openmetadata.schema.type.APIRequestMethod; + +// client is an initialized OpenMetadataClient. + +CreateAPIEndpoint request = new CreateAPIEndpoint() + .withName("addPet") + .withDisplayName("Add Pet") + .withApiCollection("sample_api_service.pet") + .withDescription("Add a new pet to the store") + .withEndpointURL(URI.create("https://petstore3.swagger.io/#/pet/addPet")) + .withRequestMethod(APIRequestMethod.POST); + +APIEndpoint endpoint = client.apiEndpoints().create(request); ``` ```bash POST /v1/apiEndpoints @@ -276,7 +281,7 @@ Returns the created API endpoint object with all specified properties and system - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -290,7 +295,7 @@ Returns the created API endpoint object with all specified properties and system - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -318,7 +323,7 @@ Returns the created API endpoint object with all specified properties and system - Type of API service (e.g., Rest). + Type of API service, for example Rest. @@ -330,7 +335,7 @@ Returns the created API endpoint object with all specified properties and system - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -352,11 +357,11 @@ Returns the created API endpoint object with all specified properties and system - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/api-endpoints/delete.mdx b/v1.13.x/api-reference/data-assets/api-endpoints/delete.mdx index d5370aa3e..2dbcc6ec3 100644 --- a/v1.13.x/api-reference/data-assets/api-endpoints/delete.mdx +++ b/v1.13.x/api-reference/data-assets/api-endpoints/delete.mdx @@ -28,7 +28,7 @@ Delete an API endpoint by ID or fully qualified name. Supports soft delete (defa Use `DELETE /v1/apiEndpoints/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the API endpoint (e.g., `sample_api_service.pet.addPet`). + Fully qualified name of the API endpoint, for example `sample_api_service.pet.addPet`. @@ -66,36 +66,40 @@ APIEndpoints.delete( hard_delete=True ) -# Delete by name -APIEndpoints.delete_by_name("sample_api_service.pet.addPet") +# Delete by name (look up the ID first) +entity = APIEndpoints.retrieve_by_name("sample_api_service.pet.addPet") +APIEndpoints.delete(entity.id) # Delete by name with options -APIEndpoints.delete_by_name( - "sample_api_service.pet.addPet", - hard_delete=True -) +entity = APIEndpoints.retrieve_by_name("sample_api_service.pet.addPet") +APIEndpoints.delete(entity.id, hard_delete=True) # Restore a soft-deleted API endpoint APIEndpoints.restore("1f61427a-4a64-4070-9ac8-1d29302dac7c") ``` ```java DELETE /v1/apiEndpoints/{id} -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -APIEndpoints.delete("1f61427a-4a64-4070-9ac8-1d29302dac7c").execute(); +client.apiEndpoints().delete("1f61427a-4a64-4070-9ac8-1d29302dac7c"); // Hard delete -APIEndpoints.delete("1f61427a-4a64-4070-9ac8-1d29302dac7c") - .hardDelete() - .execute(); +client.apiEndpoints().delete("1f61427a-4a64-4070-9ac8-1d29302dac7c", Map.of("hardDelete", "true")); // Delete by name -APIEndpoints.deleteByName("sample_api_service.pet.addPet") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/apiEndpoints/name/sample_api_service.pet.addPet", + null, + Void.class +); // Restore -APIEndpoints.restore("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +client.apiEndpoints().restore("1f61427a-4a64-4070-9ac8-1d29302dac7c"); ``` ```bash DELETE /v1/apiEndpoints/{id} diff --git a/v1.13.x/api-reference/data-assets/api-endpoints/list.mdx b/v1.13.x/api-reference/data-assets/api-endpoints/list.mdx index 47ea4d849..86b88b86b 100644 --- a/v1.13.x/api-reference/data-assets/api-endpoints/list.mdx +++ b/v1.13.x/api-reference/data-assets/api-endpoints/list.mdx @@ -51,48 +51,53 @@ configure( # List first page endpoints = APIEndpoints.list(limit=50) -for ep in endpoints.data: - print(f"{ep.fullyQualifiedName}") +for ep in endpoints.entities: + print(f"{ep.fullyQualifiedName.root}") # List all with auto-pagination for ep in APIEndpoints.list_all(): - print(f"{ep.fullyQualifiedName}") + print(f"{ep.fullyQualifiedName.root}") # Filter by API collection endpoints = APIEndpoints.list( - apiCollection="sample_api_service.pet", - fields=["owners", "tags", "domain"], + filters={"apiCollection": "sample_api_service.pet"}, + fields=["owners", "tags", "domains"], limit=50 ) -for ep in endpoints.data: - print(f"{ep.fullyQualifiedName} [{ep.requestMethod}]") +for ep in endpoints.entities: + print(f"{ep.fullyQualifiedName.root} [{ep.requestMethod.value}]") if ep.owners: - print(f" Owners: {[o.name for o in ep.owners]}") + print(f" Owners: {[o.name for o in ep.owners.root]}") if ep.tags: - print(f" Tags: {[t.tagFQN for t in ep.tags]}") + print(f" Tags: {[t.tagFQN.root for t in ep.tags]}") ``` ```java GET /v1/apiEndpoints -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.APIEndpoint; + +// client is an initialized OpenMetadataClient. // List first page -var result = APIEndpoints.list() - .limit(50) - .execute(); +ListResponse firstPage = client.apiEndpoints().list( + new ListParams().setLimit(50) +); -for (var ep : result.getData()) { +for (APIEndpoint ep : firstPage.getData()) { System.out.println(ep.getFullyQualifiedName()); } // Filter by API collection with fields -var result = APIEndpoints.list() - .apiCollection("sample_api_service.pet") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var ep : result.getData()) { +ListResponse filtered = client.apiEndpoints().list( + new ListParams() + .addFilter("apiCollection", "sample_api_service.pet") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (APIEndpoint ep : filtered.getData()) { System.out.println(ep.getFullyQualifiedName()); } ``` @@ -196,7 +201,7 @@ Returns a paginated list of API endpoint objects. By default, only basic fields - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v1.13.x/api-reference/data-assets/api-endpoints/retrieve.mdx b/v1.13.x/api-reference/data-assets/api-endpoints/retrieve.mdx index d559c9ca2..c01ae707e 100644 --- a/v1.13.x/api-reference/data-assets/api-endpoints/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/api-endpoints/retrieve.mdx @@ -16,7 +16,7 @@ Get a single API endpoint by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single API endpoint by its unique ID or fully qualified name. Use `GET /v1/apiEndpoints/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the API endpoint (e.g., `sample_api_service.pet.addPet`). + Fully qualified name of the API endpoint, for example `sample_api_service.pet.addPet`. @@ -51,7 +51,7 @@ configure( # Get by ID ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c") -print(f"{ep.fullyQualifiedName}: {ep.description}") +print(f"{ep.fullyQualifiedName.root}: {ep.name.root}") # Get by ID with fields ep = APIEndpoints.retrieve( @@ -65,31 +65,33 @@ ep = APIEndpoints.retrieve_by_name("sample_api_service.pet.addPet") # Get by name with fields ep = APIEndpoints.retrieve_by_name( "sample_api_service.pet.addPet", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/apiEndpoints/{id} -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.schema.entity.data.APIEndpoint; + +// client is an initialized OpenMetadataClient. // Get by ID -var ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +APIEndpoint ep = client.apiEndpoints().get("1f61427a-4a64-4070-9ac8-1d29302dac7c"); // Get by ID with fields -var ep = APIEndpoints.retrieve( +APIEndpoint epWithFields = client.apiEndpoints().get( "1f61427a-4a64-4070-9ac8-1d29302dac7c", "owners,tags" ); // Get by fully qualified name -var ep = APIEndpoints.retrieveByName( +APIEndpoint epByName = client.apiEndpoints().getByName( "sample_api_service.pet.addPet" ); // Get by name with fields -var ep = APIEndpoints.retrieveByName( +APIEndpoint epByNameWithFields = client.apiEndpoints().getByName( "sample_api_service.pet.addPet", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -188,7 +190,7 @@ Returns an API endpoint object with all requested fields populated. - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -202,7 +204,7 @@ Returns an API endpoint object with all requested fields populated. - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -230,7 +232,7 @@ Returns an API endpoint object with all requested fields populated. - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v1.13.x/api-reference/data-assets/api-endpoints/update.mdx b/v1.13.x/api-reference/data-assets/api-endpoints/update.mdx index 595980a7c..456768692 100644 --- a/v1.13.x/api-reference/data-assets/api-endpoints/update.mdx +++ b/v1.13.x/api-reference/data-assets/api-endpoints/update.mdx @@ -20,7 +20,7 @@ Update an API endpoint's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/apiEndpoints/name/{fqn}` to update by fully qualified name. - Fully qualified name of the API endpoint (e.g., `sample_api_service.pet.addPet`). + Fully qualified name of the API endpoint, for example `sample_api_service.pet.addPet`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -62,7 +62,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -80,7 +80,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -94,17 +94,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -126,16 +126,18 @@ ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c") ep.description = "Updated: Add a new pet to the store inventory" updated = APIEndpoints.update(ep) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/apiEndpoints/{id} -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.schema.entity.data.APIEndpoint; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +APIEndpoint ep = client.apiEndpoints().get("1f61427a-4a64-4070-9ac8-1d29302dac7c"); ep.setDescription("Updated: Add a new pet to the store inventory"); -var updated = APIEndpoints.update(ep); +APIEndpoint updated = client.apiEndpoints().update("1f61427a-4a64-4070-9ac8-1d29302dac7c", ep); ``` ```bash PATCH /v1/apiEndpoints/{id} diff --git a/v1.13.x/api-reference/data-assets/api-endpoints/versions.mdx b/v1.13.x/api-reference/data-assets/api-endpoints/versions.mdx index 81d53a748..888cda388 100644 --- a/v1.13.x/api-reference/data-assets/api-endpoints/versions.mdx +++ b/v1.13.x/api-reference/data-assets/api-endpoints/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/apiEndpoints/{id}/versions/{version}` to retrieve a specific versio - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/apiEndpoints/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import APIEndpoints @@ -40,28 +42,30 @@ configure( # List all versions versions = APIEndpoints.get_versions("1f61427a-4a64-4070-9ac8-1d29302dac7c") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version ep_v1 = APIEndpoints.get_specific_version( "1f61427a-4a64-4070-9ac8-1d29302dac7c", "0.1" ) -print(f"Original description: {ep_v1.description}") +print(f"Original description: {ep_v1.description.root if ep_v1.description else None}") ``` ```java GET /v1/apiEndpoints/{id}/versions -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.schema.entity.data.APIEndpoint; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = APIEndpoints.getVersions("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +EntityHistory history = client.apiEndpoints().getVersionList("1f61427a-4a64-4070-9ac8-1d29302dac7c"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = APIEndpoints.getSpecificVersion( +APIEndpoint v1 = client.apiEndpoints().getVersion( "1f61427a-4a64-4070-9ac8-1d29302dac7c", 0.1 ); diff --git a/v1.13.x/api-reference/data-assets/charts/create.mdx b/v1.13.x/api-reference/data-assets/charts/create.mdx index 9846abb83..a113dcd46 100644 --- a/v1.13.x/api-reference/data-assets/charts/create.mdx +++ b/v1.13.x/api-reference/data-assets/charts/create.mdx @@ -16,7 +16,7 @@ Create a new chart within a dashboard service. - Fully qualified name of the parent DashboardService (e.g., `sample_superset`). + Fully qualified name of the parent DashboardService, for example `sample_superset`. @@ -44,7 +44,7 @@ Create a new chart within a dashboard service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -53,8 +53,8 @@ Create a new chart within a dashboard service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -66,11 +66,11 @@ Create a new chart within a dashboard service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -100,21 +100,25 @@ request = CreateChartRequest( ) chart = Charts.create(request) -print(f"Created: {chart.fullyQualifiedName}") +print(f"Created: {chart.fullyQualifiedName.root}") ``` ```java POST /v1/charts -import static org.openmetadata.sdk.fluent.Charts.*; - -// Create using builder pattern -var chart = Charts.builder() - .name("114") - .displayName("# of Games That Hit 100k in Sales By Release Year") - .service("sample_superset") - .description("Bar chart showing games that hit 100k in sales by release year") - .chartType("Other") - .sourceUrl("http://localhost:808/explore/?slice_id=114") - .create(); +import org.openmetadata.schema.api.data.CreateChart; +import org.openmetadata.schema.entity.data.Chart; +import org.openmetadata.schema.type.ChartType; + +// client is an initialized OpenMetadataClient. + +CreateChart request = new CreateChart() + .withName("114") + .withDisplayName("# of Games That Hit 100k in Sales By Release Year") + .withService("sample_superset") + .withDescription("Bar chart showing games that hit 100k in sales by release year") + .withChartType(ChartType.Other) + .withSourceUrl("http://localhost:808/explore/?slice_id=114"); + +Chart chart = client.charts().create(request); ``` ```bash POST /v1/charts @@ -196,7 +200,7 @@ Returns the created chart object with all specified properties and system-genera - Type of chart visualization (e.g., Line, Bar, Area, Pie, Scatter, Table, Histogram, Other). + Type of chart visualization, for example Line, Bar, Area, Pie, Scatter, Table, Histogram, Other. @@ -226,7 +230,7 @@ Returns the created chart object with all specified properties and system-genera - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. @@ -238,7 +242,7 @@ Returns the created chart object with all specified properties and system-genera - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -260,11 +264,11 @@ Returns the created chart object with all specified properties and system-genera - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/charts/delete.mdx b/v1.13.x/api-reference/data-assets/charts/delete.mdx index 22cd4cc29..ad6b2972c 100644 --- a/v1.13.x/api-reference/data-assets/charts/delete.mdx +++ b/v1.13.x/api-reference/data-assets/charts/delete.mdx @@ -28,7 +28,7 @@ Delete a chart by ID or fully qualified name. Supports soft delete (default), ha Use `DELETE /v1/charts/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the chart (e.g., `sample_superset.114`). + Fully qualified name of the chart, for example `sample_superset.114`. @@ -66,36 +66,40 @@ Charts.delete( hard_delete=True ) -# Delete by name -Charts.delete_by_name("sample_superset.114") +# Delete by name (look up the ID first) +entity = Charts.retrieve_by_name("sample_superset.114") +Charts.delete(entity.id) # Delete by name with options -Charts.delete_by_name( - "sample_superset.114", - hard_delete=True -) +entity = Charts.retrieve_by_name("sample_superset.114") +Charts.delete(entity.id, hard_delete=True) # Restore a soft-deleted chart Charts.restore("2dde4b53-a577-424b-bbaa-18ac32eca8a9") ``` ```java DELETE /v1/charts/{id} -import static org.openmetadata.sdk.fluent.Charts.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -Charts.delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9").execute(); +client.charts().delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); // Hard delete -Charts.delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9") - .hardDelete() - .execute(); +client.charts().delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9", Map.of("hardDelete", "true")); // Delete by name -Charts.deleteByName("sample_superset.114") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/charts/name/sample_superset.114", + null, + Void.class +); // Restore -Charts.restore("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +client.charts().restore("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); ``` ```bash DELETE /v1/charts/{id} diff --git a/v1.13.x/api-reference/data-assets/charts/list.mdx b/v1.13.x/api-reference/data-assets/charts/list.mdx index 87d2e7a08..1a941a61b 100644 --- a/v1.13.x/api-reference/data-assets/charts/list.mdx +++ b/v1.13.x/api-reference/data-assets/charts/list.mdx @@ -47,49 +47,54 @@ configure( # List first page charts = Charts.list(limit=50) -for c in charts.data: - print(f"{c.fullyQualifiedName}") +for c in charts.entities: + print(f"{c.fullyQualifiedName.root}") # List all with auto-pagination for c in Charts.list_all(): - print(f"{c.fullyQualifiedName}") + print(f"{c.fullyQualifiedName.root}") # Filter by service charts = Charts.list( - service="sample_superset", + filters={"service": "sample_superset"}, fields=["owners", "tags", "domains"], limit=50 ) -for c in charts.data: - print(f"{c.fullyQualifiedName} ({c.chartType})") +for c in charts.entities: + print(f"{c.fullyQualifiedName.root} ({c.chartType.value})") if c.owners: - print(f" Owners: {[o.name for o in c.owners]}") + print(f" Owners: {[o.name for o in c.owners.root]}") if c.tags: - print(f" Tags: {[t.tagFQN for t in c.tags]}") + print(f" Tags: {[t.tagFQN.root for t in c.tags]}") ``` ```java GET /v1/charts -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.Chart; + +// client is an initialized OpenMetadataClient. // List first page -var result = Charts.list() - .limit(50) - .execute(); +ListResponse firstPage = client.charts().list( + new ListParams().setLimit(50) +); -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +for (Chart chart : firstPage.getData()) { + System.out.println(chart.getFullyQualifiedName()); } // Filter by service with fields -var result = Charts.list() - .service("sample_superset") - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +ListResponse filtered = client.charts().list( + new ListParams() + .setService("sample_superset") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (Chart chart : filtered.getData()) { + System.out.println(chart.getFullyQualifiedName()); } ``` @@ -187,7 +192,7 @@ Returns a paginated list of chart objects. By default, only basic fields are inc - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v1.13.x/api-reference/data-assets/charts/retrieve.mdx b/v1.13.x/api-reference/data-assets/charts/retrieve.mdx index ddc8cb3c7..3fd56d77c 100644 --- a/v1.13.x/api-reference/data-assets/charts/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/charts/retrieve.mdx @@ -16,7 +16,7 @@ Get a single chart by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single chart by its unique ID or fully qualified name. Use `GET /v1/charts/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the chart (e.g., `sample_superset.114`). + Fully qualified name of the chart, for example `sample_superset.114`. @@ -51,7 +51,7 @@ configure( # Get by ID chart = Charts.retrieve("2dde4b53-a577-424b-bbaa-18ac32eca8a9") -print(f"{chart.fullyQualifiedName}: {chart.displayName}") +print(f"{chart.fullyQualifiedName.root}: {chart.displayName}") # Get by ID with fields chart = Charts.retrieve( @@ -70,22 +70,26 @@ chart = Charts.retrieve_by_name( ``` ```java GET /v1/charts/{id} -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.schema.entity.data.Chart; + +// client is an initialized OpenMetadataClient. // Get by ID -var chart = Charts.retrieve("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +Chart chart = client.charts().get("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); // Get by ID with fields -var chart = Charts.retrieve( +Chart chartWithFields = client.charts().get( "2dde4b53-a577-424b-bbaa-18ac32eca8a9", "owners,tags" ); // Get by fully qualified name -var chart = Charts.retrieveByName("sample_superset.114"); +Chart chartByName = client.charts().getByName( + "sample_superset.114" +); // Get by name with fields -var chart = Charts.retrieveByName( +Chart chartByNameWithFields = client.charts().getByName( "sample_superset.114", "owners,tags,domains" ); @@ -203,7 +207,7 @@ Returns a chart object with all requested fields populated. - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v1.13.x/api-reference/data-assets/charts/update.mdx b/v1.13.x/api-reference/data-assets/charts/update.mdx index 88b1254f1..781389c09 100644 --- a/v1.13.x/api-reference/data-assets/charts/update.mdx +++ b/v1.13.x/api-reference/data-assets/charts/update.mdx @@ -20,7 +20,7 @@ Update a chart's properties using JSON Merge Patch. You can update by ID or by f Use `PATCH /v1/charts/name/{fqn}` to update by fully qualified name. - Fully qualified name of the chart (e.g., `sample_superset.114`). + Fully qualified name of the chart, for example `sample_superset.114`. ## Body Parameters @@ -52,7 +52,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,17 +66,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -99,16 +99,18 @@ chart.description = "Updated: Bar chart showing top-selling games by release yea chart.chartType = "Bar" updated = Charts.update(chart) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/charts/{id} -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.schema.entity.data.Chart; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var chart = Charts.retrieve("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +Chart chart = client.charts().get("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); chart.setDescription("Updated: Bar chart showing top-selling games by release year"); -var updated = Charts.update(chart); +Chart updated = client.charts().update("2dde4b53-a577-424b-bbaa-18ac32eca8a9", chart); ``` ```bash PATCH /v1/charts/{id} diff --git a/v1.13.x/api-reference/data-assets/charts/versions.mdx b/v1.13.x/api-reference/data-assets/charts/versions.mdx index 879d3da3f..3fbe2d8f1 100644 --- a/v1.13.x/api-reference/data-assets/charts/versions.mdx +++ b/v1.13.x/api-reference/data-assets/charts/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/charts/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/charts/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Charts @@ -40,28 +42,30 @@ configure( # List all versions versions = Charts.get_versions("2dde4b53-a577-424b-bbaa-18ac32eca8a9") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version chart_v1 = Charts.get_specific_version( "2dde4b53-a577-424b-bbaa-18ac32eca8a9", "0.1" ) -print(f"Original description: {chart_v1.description}") +print(f"Original description: {chart_v1.description.root if chart_v1.description else None}") ``` ```java GET /v1/charts/{id}/versions -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.schema.entity.data.Chart; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Charts.getVersions("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +EntityHistory history = client.charts().getVersionList("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = Charts.getSpecificVersion( +Chart v1 = client.charts().getVersion( "2dde4b53-a577-424b-bbaa-18ac32eca8a9", 0.1 ); diff --git a/v1.13.x/api-reference/data-assets/containers/create.mdx b/v1.13.x/api-reference/data-assets/containers/create.mdx index 1bd5340b9..67f0fb641 100644 --- a/v1.13.x/api-reference/data-assets/containers/create.mdx +++ b/v1.13.x/api-reference/data-assets/containers/create.mdx @@ -16,7 +16,7 @@ Create a new container within a storage service. - Fully qualified name of the parent StorageService (e.g., `s3_datalake`). + Fully qualified name of the parent StorageService, for example `s3_datalake`. @@ -42,7 +42,7 @@ Create a new container within a storage service. - Path prefix for objects in the container (e.g., `/raw/events/`). + Path prefix for objects in the container, for example `/raw/events/`. @@ -54,7 +54,7 @@ Create a new container within a storage service. - List of file formats stored in the container (e.g., `csv`, `tsv`, `parquet`, `avro`, `json`, `jsonl`, `jsonGz`, `jsonZip`). + List of file formats stored in the container, for example `csv`, `tsv`, `parquet`, `avro`, `json`, `jsonl`, `jsonGz`, `jsonZip`. @@ -74,7 +74,7 @@ Create a new container within a storage service. - Data type (e.g., `STRING`, `INT`, `DOUBLE`, `TIMESTAMP`). + Data type, for example `STRING`, `INT`, `DOUBLE`, `TIMESTAMP`. @@ -86,7 +86,7 @@ Create a new container within a storage service. - Full path of the container (e.g., `s3://analytics-bucket/raw/events`). + Full path of the container, for example `s3://analytics-bucket/raw/events`. @@ -98,7 +98,7 @@ Create a new container within a storage service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -107,8 +107,8 @@ Create a new container within a storage service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -120,11 +120,11 @@ Create a new container within a storage service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -165,23 +165,28 @@ request = CreateContainerRequest( ) container = Containers.create(request) -print(f"Created: {container.fullyQualifiedName}") +print(f"Created: {container.fullyQualifiedName.root}") ``` ```java POST /v1/containers -import static org.openmetadata.sdk.fluent.Containers.*; - -// Create using builder pattern -var container = Containers.builder() - .name("analytics-bucket") - .displayName("Analytics Bucket") - .service("s3_datalake") - .description("Primary analytics data lake bucket") - .prefix("/analytics/") - .numberOfObjects(150000) - .size(5368709120L) - .fileFormats("parquet", "json") - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateContainer; +import org.openmetadata.schema.entity.data.Container; +import org.openmetadata.schema.type.ContainerFileFormat; + +// client is an initialized OpenMetadataClient. + +CreateContainer request = new CreateContainer() + .withName("analytics-bucket") + .withDisplayName("Analytics Bucket") + .withService("s3_datalake") + .withDescription("Primary analytics data lake bucket") + .withPrefix("/analytics/") + .withNumberOfObjects(150000.0) + .withSize(5368709120.0) + .withFileFormats(List.of(ContainerFileFormat.Parquet, ContainerFileFormat.Json)); + +Container container = client.containers().create(request); ``` ```bash POST /v1/containers @@ -307,7 +312,7 @@ Returns the created container object with all specified properties and system-ge - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -353,7 +358,7 @@ Returns the created container object with all specified properties and system-ge - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -375,11 +380,11 @@ Returns the created container object with all specified properties and system-ge - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/containers/delete.mdx b/v1.13.x/api-reference/data-assets/containers/delete.mdx index 6e7ec2f34..dc3560e11 100644 --- a/v1.13.x/api-reference/data-assets/containers/delete.mdx +++ b/v1.13.x/api-reference/data-assets/containers/delete.mdx @@ -28,7 +28,7 @@ Delete a container by ID or fully qualified name. Supports soft delete (default) Use `DELETE /v1/containers/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the container (e.g., `s3_datalake.analytics-bucket`). + Fully qualified name of the container, for example `s3_datalake.analytics-bucket`. @@ -66,36 +66,40 @@ Containers.delete( hard_delete=True ) -# Delete by name -Containers.delete_by_name("s3_datalake.analytics-bucket") +# Delete by name (look up the ID first) +entity = Containers.retrieve_by_name("s3_datalake.analytics-bucket") +Containers.delete(entity.id) # Delete by name with options -Containers.delete_by_name( - "s3_datalake.analytics-bucket", - hard_delete=True, - recursive=True -) +entity = Containers.retrieve_by_name("s3_datalake.analytics-bucket") +Containers.delete(entity.id, hard_delete=True, recursive=True) # Restore a soft-deleted container Containers.restore("14744329-85c2-499e-b1fa-249fb8162341") ``` ```java DELETE /v1/containers/{id} -import static org.openmetadata.sdk.fluent.Containers.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -Containers.delete("14744329-85c2-499e-b1fa-249fb8162341").execute(); +client.containers().delete("14744329-85c2-499e-b1fa-249fb8162341"); // Hard delete -Containers.delete("14744329-85c2-499e-b1fa-249fb8162341") - .hardDelete() - .execute(); +client.containers().delete("14744329-85c2-499e-b1fa-249fb8162341", Map.of("hardDelete", "true")); // Delete by name -Containers.deleteByName("s3_datalake.analytics-bucket").execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/containers/name/s3_datalake.analytics-bucket", + null, + Void.class +); // Restore -Containers.restore("14744329-85c2-499e-b1fa-249fb8162341"); +client.containers().restore("14744329-85c2-499e-b1fa-249fb8162341"); ``` ```bash DELETE /v1/containers/{id} diff --git a/v1.13.x/api-reference/data-assets/containers/list.mdx b/v1.13.x/api-reference/data-assets/containers/list.mdx index 49abe6bbe..a50a0ef38 100644 --- a/v1.13.x/api-reference/data-assets/containers/list.mdx +++ b/v1.13.x/api-reference/data-assets/containers/list.mdx @@ -28,7 +28,7 @@ List all containers with optional filtering and pagination. - Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `children`, `sourceHash`. See [Supported Fields](#supported-fields) below. + Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `sourceHash`. See [Supported Fields](#supported-fields) below. @@ -47,49 +47,54 @@ configure( # List first page containers = Containers.list(limit=50) -for c in containers.data: - print(f"{c.fullyQualifiedName}") +for c in containers.entities: + print(f"{c.fullyQualifiedName.root}") # List all with auto-pagination for c in Containers.list_all(): - print(f"{c.fullyQualifiedName}") + print(f"{c.fullyQualifiedName.root}") # Filter by storage service containers = Containers.list( - service="s3_datalake", + filters={"service": "s3_datalake"}, fields=["owners", "tags", "dataModel"], limit=50 ) -for c in containers.data: - print(f"{c.fullyQualifiedName}") +for c in containers.entities: + print(f"{c.fullyQualifiedName.root}") if c.owners: - print(f" Owners: {[o.name for o in c.owners]}") + print(f" Owners: {[o.name for o in c.owners.root]}") if c.tags: - print(f" Tags: {[t.tagFQN for t in c.tags]}") + print(f" Tags: {[t.tagFQN.root for t in c.tags]}") ``` ```java GET /v1/containers -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.Container; + +// client is an initialized OpenMetadataClient. // List first page -var result = Containers.list() - .limit(50) - .execute(); +ListResponse firstPage = client.containers().list( + new ListParams().setLimit(50) +); -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +for (Container container : firstPage.getData()) { + System.out.println(container.getFullyQualifiedName()); } -// Filter by storage service with fields -var result = Containers.list() - .service("s3_datalake") - .fields("owners", "tags", "dataModel") - .limit(50) - .execute(); +// Filter by service with fields +ListResponse filtered = client.containers().list( + new ListParams() + .setService("s3_datalake") + .setFields("owners,tags,dataModel") + .setLimit(50) +); -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +for (Container container : filtered.getData()) { + System.out.println(container.getFullyQualifiedName()); } ``` @@ -103,7 +108,7 @@ curl "{base_url}/api/v1/containers?service=s3_datalake&limit=50" \ -H "Authorization: Bearer {access_token}" # With fields -curl "{base_url}/api/v1/containers?service=s3_datalake&fields=owners,tags,dataModel,children&limit=50" \ +curl "{base_url}/api/v1/containers?service=s3_datalake&fields=owners,tags,dataModel&limit=50" \ -H "Authorization: Bearer {access_token}" ``` @@ -186,7 +191,7 @@ Returns a paginated list of container objects. By default, only basic fields are - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -229,10 +234,6 @@ Returns a paginated list of container objects. By default, only basic fields are Data model describing the schema of files. Only included when `fields` contains `dataModel`. - - Nested child containers. Only included when `fields` contains `children`. - - Custom properties. Only included when `fields` contains `extension`. @@ -272,7 +273,6 @@ The following fields can be requested via the `fields` query parameter: | `extension` | Custom property values | | `domains` | Domain assignments for governance | | `dataModel` | Data model with column definitions | -| `children` | Nested child containers | | `sourceHash` | Hash for change detection | --- diff --git a/v1.13.x/api-reference/data-assets/containers/retrieve.mdx b/v1.13.x/api-reference/data-assets/containers/retrieve.mdx index cdd8cebd7..ba7e84161 100644 --- a/v1.13.x/api-reference/data-assets/containers/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/containers/retrieve.mdx @@ -16,7 +16,7 @@ Get a single container by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,dataModel,children,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,dataModel,sourceHash`. @@ -28,11 +28,11 @@ Get a single container by its unique ID or fully qualified name. Use `GET /v1/containers/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the container (e.g., `s3_datalake.analytics-bucket`). + Fully qualified name of the container, for example `s3_datalake.analytics-bucket`. - Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `children`, `sourceHash`. + Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `sourceHash`. @@ -51,12 +51,12 @@ configure( # Get by ID container = Containers.retrieve("14744329-85c2-499e-b1fa-249fb8162341") -print(f"{container.fullyQualifiedName}: {container.description}") +print(f"{container.fullyQualifiedName.root}: {container.name.root}") # Get by ID with fields container = Containers.retrieve( "14744329-85c2-499e-b1fa-249fb8162341", - fields=["owners", "tags", "dataModel", "children"] + fields=["owners", "tags", "dataModel"] ) # Get by fully qualified name @@ -65,29 +65,33 @@ container = Containers.retrieve_by_name("s3_datalake.analytics-bucket") # Get by name with fields container = Containers.retrieve_by_name( "s3_datalake.analytics-bucket", - fields=["owners", "tags", "dataModel", "children"] + fields=["owners", "tags", "dataModel"] ) ``` ```java GET /v1/containers/{id} -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.schema.entity.data.Container; + +// client is an initialized OpenMetadataClient. // Get by ID -var container = Containers.retrieve("14744329-85c2-499e-b1fa-249fb8162341"); +Container container = client.containers().get("14744329-85c2-499e-b1fa-249fb8162341"); // Get by ID with fields -var container = Containers.retrieve( +Container containerWithFields = client.containers().get( "14744329-85c2-499e-b1fa-249fb8162341", - "owners,tags,dataModel,children" + "owners,tags,dataModel" ); // Get by fully qualified name -var container = Containers.retrieveByName("s3_datalake.analytics-bucket"); +Container containerByName = client.containers().getByName( + "s3_datalake.analytics-bucket" +); // Get by name with fields -var container = Containers.retrieveByName( +Container containerByNameWithFields = client.containers().getByName( "s3_datalake.analytics-bucket", - "owners,tags,dataModel,children" + "owners,tags,dataModel" ); ``` @@ -97,7 +101,7 @@ curl "{base_url}/api/v1/containers/14744329-85c2-499e-b1fa-249fb8162341" \ -H "Authorization: Bearer {access_token}" # Get by ID with fields -curl "{base_url}/api/v1/containers/14744329-85c2-499e-b1fa-249fb8162341?fields=owners,tags,dataModel,children" \ +curl "{base_url}/api/v1/containers/14744329-85c2-499e-b1fa-249fb8162341?fields=owners,tags,dataModel" \ -H "Authorization: Bearer {access_token}" # Get by fully qualified name @@ -105,7 +109,7 @@ curl "{base_url}/api/v1/containers/name/s3_datalake.analytics-bucket" \ -H "Authorization: Bearer {access_token}" # Get by name with fields -curl "{base_url}/api/v1/containers/name/s3_datalake.analytics-bucket?fields=owners,tags,dataModel,children" \ +curl "{base_url}/api/v1/containers/name/s3_datalake.analytics-bucket?fields=owners,tags,dataModel" \ -H "Authorization: Bearer {access_token}" ``` @@ -207,7 +211,7 @@ Returns a container object with all requested fields populated. - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -224,10 +228,6 @@ Returns a container object with all requested fields populated. - - Nested child containers. Only included when `fields` contains `children`. - - Version number for the entity. diff --git a/v1.13.x/api-reference/data-assets/containers/update.mdx b/v1.13.x/api-reference/data-assets/containers/update.mdx index 7e81596ae..a968da596 100644 --- a/v1.13.x/api-reference/data-assets/containers/update.mdx +++ b/v1.13.x/api-reference/data-assets/containers/update.mdx @@ -20,7 +20,7 @@ Update a container's properties using JSON Merge Patch. You can update by ID or Use `PATCH /v1/containers/name/{fqn}` to update by fully qualified name. - Fully qualified name of the container (e.g., `s3_datalake.analytics-bucket`). + Fully qualified name of the container, for example `s3_datalake.analytics-bucket`. ## Body Parameters @@ -74,7 +74,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -88,17 +88,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -122,16 +122,18 @@ container.numberOfObjects = 175000 container.size = 6442450944 updated = Containers.update(container) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/containers/{id} -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.schema.entity.data.Container; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var container = Containers.retrieve("14744329-85c2-499e-b1fa-249fb8162341"); +Container container = client.containers().get("14744329-85c2-499e-b1fa-249fb8162341"); container.setDescription("Updated: Primary analytics bucket with partitioned parquet data"); -var updated = Containers.update(container); +Container updated = client.containers().update("14744329-85c2-499e-b1fa-249fb8162341", container); ``` ```bash PATCH /v1/containers/{id} diff --git a/v1.13.x/api-reference/data-assets/containers/versions.mdx b/v1.13.x/api-reference/data-assets/containers/versions.mdx index 0a21c1351..711b51e0f 100644 --- a/v1.13.x/api-reference/data-assets/containers/versions.mdx +++ b/v1.13.x/api-reference/data-assets/containers/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/containers/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/containers/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Containers @@ -40,28 +42,30 @@ configure( # List all versions versions = Containers.get_versions("14744329-85c2-499e-b1fa-249fb8162341") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version container_v1 = Containers.get_specific_version( "14744329-85c2-499e-b1fa-249fb8162341", "0.1" ) -print(f"Original description: {container_v1.description}") +print(f"Original description: {container_v1.description.root if container_v1.description else None}") ``` ```java GET /v1/containers/{id}/versions -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.schema.entity.data.Container; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Containers.getVersions("14744329-85c2-499e-b1fa-249fb8162341"); +EntityHistory history = client.containers().getVersionList("14744329-85c2-499e-b1fa-249fb8162341"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = Containers.getSpecificVersion( +Container v1 = client.containers().getVersion( "14744329-85c2-499e-b1fa-249fb8162341", 0.1 ); diff --git a/v1.13.x/api-reference/data-assets/dashboard-services/create.mdx b/v1.13.x/api-reference/data-assets/dashboard-services/create.mdx index 71cb5b5cb..480b48640 100644 --- a/v1.13.x/api-reference/data-assets/dashboard-services/create.mdx +++ b/v1.13.x/api-reference/data-assets/dashboard-services/create.mdx @@ -16,7 +16,7 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Type of dashboard service (e.g., `Superset`, `Looker`, `Tableau`, `Metabase`, `Redash`, `PowerBI`, `Mode`, `QlikSense`, `QlikCloud`, `Lightdash`, `DomoDashboard`, `CustomDashboard`). + Type of dashboard service, for example `Superset`, `Looker`, `Tableau`, `Metabase`, `Redash`, `PowerBI`, `Mode`, `QlikSense`, `QlikCloud`, `Lightdash`, `DomoDashboard`, `CustomDashboard`. @@ -32,7 +32,7 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Service-specific connection configuration (e.g., hostPort, username, password for Superset). + Service-specific connection configuration, for example hostPort, username, password for Superset. @@ -46,7 +46,7 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new dashboard service connection to a platform such as Superset, Looker - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -112,16 +112,26 @@ print(f"Created: {service['fullyQualifiedName']}") ``` ```java POST /v1/services/dashboardServices -import static org.openmetadata.sdk.fluent.DashboardServices.*; - -DashboardService service = DashboardServices.builder() - .name("sample_looker") - .serviceType("Looker") - .connection(lookerConnection() - .clientId("your-client-id") - .clientSecret("***") - .hostPort("https://looker.example.com:443")) - .create(); +import org.openmetadata.schema.api.data.CreateDashboardDataModel.DashboardServiceType; +import org.openmetadata.schema.api.services.CreateDashboardService; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.schema.services.connections.dashboard.LookerConnection; +import org.openmetadata.schema.type.DashboardConnection; +import org.openmetadata.sdk.fluent.DashboardServices; +import java.net.URI; + +CreateDashboardService request = new CreateDashboardService() + .withName("sample_looker") + .withDisplayName("Sample Looker") + .withServiceType(DashboardServiceType.Looker) + .withDescription("Production Looker instance") + .withConnection(new DashboardConnection().withConfig( + new LookerConnection() + .withClientId("your-client-id") + .withClientSecret("***") + .withHostPort(URI.create("https://looker.example.com:443")))); + +DashboardService service = DashboardServices.create(request); ``` ```bash POST /v1/services/dashboardServices @@ -201,7 +211,7 @@ Returns the created dashboard service object with all specified properties and s - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. @@ -223,7 +233,7 @@ Returns the created dashboard service object with all specified properties and s - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -232,7 +242,7 @@ Returns the created dashboard service object with all specified properties and s - + Fully qualified name of the assigned domain. @@ -245,11 +255,11 @@ Returns the created dashboard service object with all specified properties and s - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/dashboard-services/delete.mdx b/v1.13.x/api-reference/data-assets/dashboard-services/delete.mdx index de55ba160..d5885b92e 100644 --- a/v1.13.x/api-reference/data-assets/dashboard-services/delete.mdx +++ b/v1.13.x/api-reference/data-assets/dashboard-services/delete.mdx @@ -28,7 +28,7 @@ Delete a dashboard service by ID or fully qualified name. Supports soft delete ( Use `DELETE /v1/services/dashboardServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. @@ -84,7 +84,10 @@ response = requests.put( ``` ```java DELETE /v1/services/dashboardServices/{id} -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.fluent.DashboardServices; + +// client is an initialized OpenMetadataClient. // Soft delete DashboardServices.delete("2c0c7c05-d820-4bea-a471-047deb7f92fd").execute(); @@ -94,11 +97,12 @@ DashboardServices.delete("2c0c7c05-d820-4bea-a471-047deb7f92fd") .hardDelete() .execute(); -// Delete by name -DashboardServices.deleteByName("sample_looker").execute(); +// Delete by name (look up the ID first) +DashboardService service = DashboardServices.retrieveByName("sample_looker"); +DashboardServices.delete(service.getId()).execute(); -// Restore -DashboardServices.restore("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +// Restore. The fluent class has no restore method, so use the client service. +client.dashboardServices().restore("2c0c7c05-d820-4bea-a471-047deb7f92fd"); ``` ```bash DELETE /v1/services/dashboardServices/{id} diff --git a/v1.13.x/api-reference/data-assets/dashboard-services/import-export.mdx b/v1.13.x/api-reference/data-assets/dashboard-services/import-export.mdx index 338b3d2db..04fdd6f38 100644 --- a/v1.13.x/api-reference/data-assets/dashboard-services/import-export.mdx +++ b/v1.13.x/api-reference/data-assets/dashboard-services/import-export.mdx @@ -14,7 +14,7 @@ Export dashboard service metadata (dashboards, charts, owners, tags) to CSV and `GET /v1/services/dashboardServices/name/{fqn}/export` - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. ## Export Async @@ -88,38 +88,6 @@ response = requests.put( ) ``` -```java GET /v1/services/dashboardServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.DashboardServices; - -// Synchronous export -String csvData = DashboardServices.exportCsv("sample_looker") - .execute(); - -// Async export -String jobId = DashboardServices.exportCsv("sample_looker") - .async() - .execute(); - -// Synchronous import (dry run) -String result = DashboardServices.importCsv("sample_looker") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = DashboardServices.importCsv("sample_looker") - .withData(csvData) - .dryRun(false) - .execute(); - -// Async import -String jobId = DashboardServices.importCsv("sample_looker") - .withData(csvData) - .dryRun(false) - .async() - .execute(); -``` - ```bash GET /v1/services/dashboardServices/name/{fqn}/export # Export to CSV curl "{base_url}/api/v1/services/dashboardServices/name/sample_looker/export" \ diff --git a/v1.13.x/api-reference/data-assets/dashboard-services/list.mdx b/v1.13.x/api-reference/data-assets/dashboard-services/list.mdx index b5bbfb9a6..3bae0ef39 100644 --- a/v1.13.x/api-reference/data-assets/dashboard-services/list.mdx +++ b/v1.13.x/api-reference/data-assets/dashboard-services/list.mdx @@ -59,22 +59,23 @@ response = requests.get( ``` ```java GET /v1/services/dashboardServices -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = DashboardServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.dashboardServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (DashboardService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } // With fields -var result = DashboardServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); +ListResponse withFields = client.dashboardServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/dashboardServices @@ -144,7 +145,7 @@ Returns a paginated list of dashboard service objects. By default, only basic fi - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v1.13.x/api-reference/data-assets/dashboard-services/retrieve.mdx b/v1.13.x/api-reference/data-assets/dashboard-services/retrieve.mdx index 2aba0a945..0703ad50a 100644 --- a/v1.13.x/api-reference/data-assets/dashboard-services/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/dashboard-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single dashboard service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single dashboard service by its unique ID or fully qualified name. Use `GET /v1/services/dashboardServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. @@ -71,22 +71,23 @@ response = requests.get( ``` ```java GET /v1/services/dashboardServices/{id} -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.fluent.DashboardServices; // Get by ID -var svc = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +DashboardService service = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); // Get by ID with fields -var svc = DashboardServices.retrieve( +DashboardService serviceWithFields = DashboardServices.retrieve( "2c0c7c05-d820-4bea-a471-047deb7f92fd", "owners,tags,domains" ); // Get by fully qualified name -var svc = DashboardServices.retrieveByName("sample_looker"); +DashboardService serviceByName = DashboardServices.retrieveByName("sample_looker"); // Get by name with fields -var svc = DashboardServices.retrieveByName("sample_looker", "owners,tags,domains"); +DashboardService serviceByNameWithFields = DashboardServices.retrieveByName("sample_looker", "owners,tags,domains"); ``` ```bash GET /v1/services/dashboardServices/{id} @@ -156,7 +157,7 @@ Returns a dashboard service object with all requested fields populated. - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. diff --git a/v1.13.x/api-reference/data-assets/dashboard-services/update.mdx b/v1.13.x/api-reference/data-assets/dashboard-services/update.mdx index 902695aa5..f9a9defc4 100644 --- a/v1.13.x/api-reference/data-assets/dashboard-services/update.mdx +++ b/v1.13.x/api-reference/data-assets/dashboard-services/update.mdx @@ -20,7 +20,7 @@ Update a dashboard service's properties using JSON Merge Patch. You can update b Use `PATCH /v1/services/dashboardServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -108,12 +108,13 @@ print(f"Updated to version {service['version']}") ``` ```java PATCH /v1/services/dashboardServices/{id} -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.fluent.DashboardServices; // Retrieve, modify, and update -var svc = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); -svc.setDescription("Updated Looker production instance"); -var updated = DashboardServices.update(svc); +DashboardService service = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +service.setDescription("Updated Looker production instance"); +DashboardService updated = DashboardServices.update(service); ``` ```bash PATCH /v1/services/dashboardServices/{id} diff --git a/v1.13.x/api-reference/data-assets/dashboard-services/versions.mdx b/v1.13.x/api-reference/data-assets/dashboard-services/versions.mdx index c9b41cc49..9f92d6666 100644 --- a/v1.13.x/api-reference/data-assets/dashboard-services/versions.mdx +++ b/v1.13.x/api-reference/data-assets/dashboard-services/versions.mdx @@ -24,7 +24,7 @@ Use `GET /v1/services/dashboardServices/{id}/versions/{version}` to retrieve a s - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. @@ -54,20 +54,20 @@ response = requests.get( ``` ```java GET /v1/services/dashboardServices/{id}/versions -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = DashboardServices.getVersions("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +EntityHistory history = client.dashboardServices().getVersionList("2c0c7c05-d820-4bea-a471-047deb7f92fd"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = DashboardServices.getSpecificVersion( - "2c0c7c05-d820-4bea-a471-047deb7f92fd", - 0.1 -); +DashboardService v1 = client.dashboardServices().getVersion("2c0c7c05-d820-4bea-a471-047deb7f92fd", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/dashboards/create.mdx b/v1.13.x/api-reference/data-assets/dashboards/create.mdx index 28db09886..94d7c821d 100644 --- a/v1.13.x/api-reference/data-assets/dashboards/create.mdx +++ b/v1.13.x/api-reference/data-assets/dashboards/create.mdx @@ -16,7 +16,7 @@ Create a new dashboard within a dashboard service. - Fully qualified name of the parent DashboardService (e.g., `sample_superset`). + Fully qualified name of the parent DashboardService, for example `sample_superset`. @@ -44,7 +44,7 @@ Create a new dashboard within a dashboard service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -53,8 +53,8 @@ Create a new dashboard within a dashboard service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -66,11 +66,11 @@ Create a new dashboard within a dashboard service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -99,20 +99,23 @@ request = CreateDashboardRequest( ) dashboard = Dashboards.create(request) -print(f"Created: {dashboard.fullyQualifiedName}") +print(f"Created: {dashboard.fullyQualifiedName.root}") ``` ```java POST /v1/dashboards -import static org.openmetadata.sdk.fluent.Dashboards.*; - -// Create using builder pattern -var dashboard = Dashboards.builder() - .name("10") - .displayName("deck.gl Demo") - .service("sample_superset") - .description("Dashboard showcasing deck.gl visualizations") - .sourceUrl("http://localhost:808/superset/dashboard/10/") - .create(); +import org.openmetadata.schema.api.data.CreateDashboard; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. + +CreateDashboard request = new CreateDashboard() + .withName("10") + .withDisplayName("deck.gl Demo") + .withService("sample_superset") + .withDescription("Dashboard showcasing deck.gl visualizations") + .withSourceUrl("http://localhost:808/superset/dashboard/10/"); + +Dashboard dashboard = client.dashboards().create(request); ``` ```bash POST /v1/dashboards @@ -219,7 +222,7 @@ Returns the created dashboard object with all specified properties and system-ge - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. @@ -235,7 +238,7 @@ Returns the created dashboard object with all specified properties and system-ge - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -257,11 +260,11 @@ Returns the created dashboard object with all specified properties and system-ge - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/dashboards/delete.mdx b/v1.13.x/api-reference/data-assets/dashboards/delete.mdx index fdff6d9f5..0fce19cce 100644 --- a/v1.13.x/api-reference/data-assets/dashboards/delete.mdx +++ b/v1.13.x/api-reference/data-assets/dashboards/delete.mdx @@ -28,7 +28,7 @@ Delete a dashboard by ID or fully qualified name. Supports soft delete (default) Use `DELETE /v1/dashboards/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the dashboard (e.g., `sample_superset.10`). + Fully qualified name of the dashboard, for example `sample_superset.10`. @@ -66,36 +66,40 @@ Dashboards.delete( hard_delete=True ) -# Delete by name -Dashboards.delete_by_name("sample_superset.10") +# Delete by name (look up the ID first) +entity = Dashboards.retrieve_by_name("sample_superset.10") +Dashboards.delete(entity.id) # Delete by name with options -Dashboards.delete_by_name( - "sample_superset.10", - hard_delete=True -) +entity = Dashboards.retrieve_by_name("sample_superset.10") +Dashboards.delete(entity.id, hard_delete=True) # Restore a soft-deleted dashboard Dashboards.restore("03fb5cc3-de48-423f-9926-8e192e5de59d") ``` ```java DELETE /v1/dashboards/{id} -import static org.openmetadata.sdk.fluent.Dashboards.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -Dashboards.delete("03fb5cc3-de48-423f-9926-8e192e5de59d").execute(); +client.dashboards().delete("03fb5cc3-de48-423f-9926-8e192e5de59d"); // Hard delete -Dashboards.delete("03fb5cc3-de48-423f-9926-8e192e5de59d") - .hardDelete() - .execute(); +client.dashboards().delete("03fb5cc3-de48-423f-9926-8e192e5de59d", Map.of("hardDelete", "true")); // Delete by name -Dashboards.deleteByName("sample_superset.10") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/dashboards/name/sample_superset.10", + null, + Void.class +); // Restore -Dashboards.restore("03fb5cc3-de48-423f-9926-8e192e5de59d"); +client.dashboards().restore("03fb5cc3-de48-423f-9926-8e192e5de59d"); ``` ```bash DELETE /v1/dashboards/{id} diff --git a/v1.13.x/api-reference/data-assets/dashboards/followers-votes.mdx b/v1.13.x/api-reference/data-assets/dashboards/followers-votes.mdx index d13baa472..686650713 100644 --- a/v1.13.x/api-reference/data-assets/dashboards/followers-votes.mdx +++ b/v1.13.x/api-reference/data-assets/dashboards/followers-votes.mdx @@ -51,7 +51,7 @@ Manage followers and votes for dashboard entities. ```python PUT /v1/dashboards/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Dashboards configure( @@ -59,39 +59,62 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + dashboard_id = "03fb5cc3-de48-423f-9926-8e192e5de59d" user_id = "user-uuid-here" # Add a follower dashboard = Dashboards.add_followers(dashboard_id, [user_id]) -print(f"Followers: {len(dashboard.followers)}") +print(f"Followers: {len(dashboard.followers.root)}") # Remove a follower dashboard = Dashboards.remove_followers(dashboard_id, [user_id]) # Add a vote -dashboard = Dashboards.add_vote(dashboard_id, vote_type="votedUp") +rest.put(f"/dashboards/{dashboard_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -dashboard = Dashboards.remove_vote(dashboard_id) +rest.put(f"/dashboards/{dashboard_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/dashboards/{id}/followers -import static org.openmetadata.sdk.fluent.Dashboards.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String dashboardId = "03fb5cc3-de48-423f-9926-8e192e5de59d"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; // Add a follower -Dashboards.addFollower(dashboardId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/dashboards/" + dashboardId + "/followers", + UUID.fromString(userId) +); // Remove a follower -Dashboards.removeFollower(dashboardId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/dashboards/" + dashboardId + "/followers/" + userId, + null +); // Add a vote -Dashboards.vote(dashboardId, "votedUp"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/dashboards/" + dashboardId + "/vote", + Map.of("updatedVoteType", "votedUp") +); // Remove a vote -Dashboards.vote(dashboardId, "unVoted"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/dashboards/" + dashboardId + "/vote", + Map.of("updatedVoteType", "unVoted") +); ``` ```bash PUT /v1/dashboards/{id}/followers diff --git a/v1.13.x/api-reference/data-assets/dashboards/list.mdx b/v1.13.x/api-reference/data-assets/dashboards/list.mdx index 70171ee6e..22fc27e9a 100644 --- a/v1.13.x/api-reference/data-assets/dashboards/list.mdx +++ b/v1.13.x/api-reference/data-assets/dashboards/list.mdx @@ -47,49 +47,54 @@ configure( # List first page dashboards = Dashboards.list(limit=50) -for d in dashboards.data: - print(f"{d.fullyQualifiedName}") +for d in dashboards.entities: + print(f"{d.fullyQualifiedName.root}") # List all with auto-pagination for d in Dashboards.list_all(): - print(f"{d.fullyQualifiedName}") + print(f"{d.fullyQualifiedName.root}") # Filter by service dashboards = Dashboards.list( - service="sample_superset", + filters={"service": "sample_superset"}, fields=["owners", "tags", "charts"], limit=50 ) -for d in dashboards.data: - print(f"{d.fullyQualifiedName}") +for d in dashboards.entities: + print(f"{d.fullyQualifiedName.root}") if d.owners: - print(f" Owners: {[o.name for o in d.owners]}") + print(f" Owners: {[o.name for o in d.owners.root]}") if d.tags: - print(f" Tags: {[t.tagFQN for t in d.tags]}") + print(f" Tags: {[t.tagFQN.root for t in d.tags]}") ``` ```java GET /v1/dashboards -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. // List first page -var result = Dashboards.list() - .limit(50) - .execute(); +ListResponse firstPage = client.dashboards().list( + new ListParams().setLimit(50) +); -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +for (Dashboard dashboard : firstPage.getData()) { + System.out.println(dashboard.getFullyQualifiedName()); } // Filter by service with fields -var result = Dashboards.list() - .service("sample_superset") - .fields("owners", "tags", "charts") - .limit(50) - .execute(); - -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +ListResponse filtered = client.dashboards().list( + new ListParams() + .setService("sample_superset") + .setFields("owners,tags,charts") + .setLimit(50) +); + +for (Dashboard dashboard : filtered.getData()) { + System.out.println(dashboard.getFullyQualifiedName()); } ``` @@ -191,7 +196,7 @@ Returns a paginated list of dashboard objects. By default, only basic fields are - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v1.13.x/api-reference/data-assets/dashboards/retrieve.mdx b/v1.13.x/api-reference/data-assets/dashboards/retrieve.mdx index 482070f33..75f6f4246 100644 --- a/v1.13.x/api-reference/data-assets/dashboards/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/dashboards/retrieve.mdx @@ -16,7 +16,7 @@ Get a single dashboard by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,charts,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,charts,sourceHash`. @@ -28,7 +28,7 @@ Get a single dashboard by its unique ID or fully qualified name. Use `GET /v1/dashboards/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the dashboard (e.g., `sample_superset.10`). + Fully qualified name of the dashboard, for example `sample_superset.10`. @@ -51,7 +51,7 @@ configure( # Get by ID dashboard = Dashboards.retrieve("03fb5cc3-de48-423f-9926-8e192e5de59d") -print(f"{dashboard.fullyQualifiedName}: {dashboard.displayName}") +print(f"{dashboard.fullyQualifiedName.root}: {dashboard.displayName}") # Get by ID with fields dashboard = Dashboards.retrieve( @@ -70,22 +70,26 @@ dashboard = Dashboards.retrieve_by_name( ``` ```java GET /v1/dashboards/{id} -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. // Get by ID -var dashboard = Dashboards.retrieve("03fb5cc3-de48-423f-9926-8e192e5de59d"); +Dashboard dashboard = client.dashboards().get("03fb5cc3-de48-423f-9926-8e192e5de59d"); // Get by ID with fields -var dashboard = Dashboards.retrieve( +Dashboard dashboardWithFields = client.dashboards().get( "03fb5cc3-de48-423f-9926-8e192e5de59d", "owners,tags,charts" ); // Get by fully qualified name -var dashboard = Dashboards.retrieveByName("sample_superset.10"); +Dashboard dashboardByName = client.dashboards().getByName( + "sample_superset.10" +); // Get by name with fields -var dashboard = Dashboards.retrieveByName( +Dashboard dashboardByNameWithFields = client.dashboards().getByName( "sample_superset.10", "owners,tags,charts,domains" ); @@ -207,7 +211,7 @@ Returns a dashboard object with all requested fields populated. - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v1.13.x/api-reference/data-assets/dashboards/update.mdx b/v1.13.x/api-reference/data-assets/dashboards/update.mdx index 58fa8be74..9da6c6d1f 100644 --- a/v1.13.x/api-reference/data-assets/dashboards/update.mdx +++ b/v1.13.x/api-reference/data-assets/dashboards/update.mdx @@ -20,7 +20,7 @@ Update a dashboard's properties using JSON Merge Patch. You can update by ID or Use `PATCH /v1/dashboards/name/{fqn}` to update by fully qualified name. - Fully qualified name of the dashboard (e.g., `sample_superset.10`). + Fully qualified name of the dashboard, for example `sample_superset.10`. ## Body Parameters @@ -52,7 +52,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,17 +66,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -99,16 +99,18 @@ dashboard.description = "Updated: deck.gl Demo dashboard with new visualizations dashboard.displayName = "deck.gl Demo v2" updated = Dashboards.update(dashboard) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dashboards/{id} -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var dashboard = Dashboards.retrieve("03fb5cc3-de48-423f-9926-8e192e5de59d"); +Dashboard dashboard = client.dashboards().get("03fb5cc3-de48-423f-9926-8e192e5de59d"); dashboard.setDescription("Updated: deck.gl Demo dashboard with new visualizations"); -var updated = Dashboards.update(dashboard); +Dashboard updated = client.dashboards().update("03fb5cc3-de48-423f-9926-8e192e5de59d", dashboard); ``` ```bash PATCH /v1/dashboards/{id} diff --git a/v1.13.x/api-reference/data-assets/dashboards/versions.mdx b/v1.13.x/api-reference/data-assets/dashboards/versions.mdx index 4bce3046b..bc288b1f2 100644 --- a/v1.13.x/api-reference/data-assets/dashboards/versions.mdx +++ b/v1.13.x/api-reference/data-assets/dashboards/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dashboards/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dashboards/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Dashboards @@ -40,28 +42,30 @@ configure( # List all versions versions = Dashboards.get_versions("03fb5cc3-de48-423f-9926-8e192e5de59d") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version dashboard_v1 = Dashboards.get_specific_version( "03fb5cc3-de48-423f-9926-8e192e5de59d", "0.1" ) -print(f"Original description: {dashboard_v1.description}") +print(f"Original description: {dashboard_v1.description.root if dashboard_v1.description else None}") ``` ```java GET /v1/dashboards/{id}/versions -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.schema.entity.data.Dashboard; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Dashboards.getVersions("03fb5cc3-de48-423f-9926-8e192e5de59d"); +EntityHistory history = client.dashboards().getVersionList("03fb5cc3-de48-423f-9926-8e192e5de59d"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = Dashboards.getSpecificVersion( +Dashboard v1 = client.dashboards().getVersion( "03fb5cc3-de48-423f-9926-8e192e5de59d", 0.1 ); diff --git a/v1.13.x/api-reference/data-assets/database-schemas/advanced.mdx b/v1.13.x/api-reference/data-assets/database-schemas/advanced.mdx index b446aa8d4..fd8eb9e08 100644 --- a/v1.13.x/api-reference/data-assets/database-schemas/advanced.mdx +++ b/v1.13.x/api-reference/data-assets/database-schemas/advanced.mdx @@ -53,19 +53,19 @@ Manage followers, votes, and profiler configuration for database schema entities ### Get Profiler Config -`GET /v1/databaseSchemas/{id}/profilerConfig` +`GET /v1/databaseSchemas/{id}/databaseSchemaProfilerConfig` ### Set Profiler Config -`PUT /v1/databaseSchemas/{id}/profilerConfig` +`PUT /v1/databaseSchemas/{id}/databaseSchemaProfilerConfig` ### Delete Profiler Config -`DELETE /v1/databaseSchemas/{id}/profilerConfig` +`DELETE /v1/databaseSchemas/{id}/databaseSchemaProfilerConfig` ```python PUT /v1/databaseSchemas/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import DatabaseSchemas configure( @@ -73,27 +73,30 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + schema_id = "770e8400-e29b-41d4-a716-446655440000" user_id = "user-uuid-here" # Add a follower schema = DatabaseSchemas.add_followers(schema_id, [user_id]) -print(f"Followers: {len(schema.followers)}") +print(f"Followers: {len(schema.followers.root)}") # Remove a follower schema = DatabaseSchemas.remove_followers(schema_id, [user_id]) # Add a vote -schema = DatabaseSchemas.add_vote(schema_id, vote_type="votedUp") +rest.put(f"/databaseSchemas/{schema_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -schema = DatabaseSchemas.remove_vote(schema_id) +rest.put(f"/databaseSchemas/{schema_id}/vote", json={"updatedVoteType": "unVoted"}) # Get profiler config -config = DatabaseSchemas.get_profiler_config(schema_id) +schema = DatabaseSchemas.retrieve(schema_id, fields=["databaseSchemaProfilerConfig"]) +print(schema.databaseSchemaProfilerConfig) # Set profiler config -DatabaseSchemas.set_profiler_config(schema_id, { +rest.put(f"/databaseSchemas/{schema_id}/databaseSchemaProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": { @@ -105,17 +108,72 @@ DatabaseSchemas.set_profiler_config(schema_id, { }) # Delete profiler config -DatabaseSchemas.delete_profiler_config(schema_id) +rest.delete(f"/databaseSchemas/{schema_id}/databaseSchemaProfilerConfig") ``` ```java PUT /v1/databaseSchemas/{id}/followers -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.schema.type.DatabaseSchemaProfilerConfig; +import org.openmetadata.sdk.network.HttpMethod; -String schemaId = "770e8400-e29b-41d4-a716-446655440000"; +// client is an initialized OpenMetadataClient. -// Followers - use REST client directly -// Votes and profiler config - use REST client directly -// See curl examples for request format +String schemaId = "770e8400-e29b-41d4-a716-446655440000"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; + +// Add a follower +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/followers", + UUID.fromString(userId) +); + +// Remove a follower +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databaseSchemas/" + schemaId + "/followers/" + userId, + null +); + +// Add a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/vote", + Map.of("updatedVoteType", "votedUp") +); + +// Remove a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/vote", + Map.of("updatedVoteType", "unVoted") +); + +// Get profiler config +DatabaseSchema schema = client.databaseSchemas().get(schemaId, "databaseSchemaProfilerConfig"); +DatabaseSchemaProfilerConfig profilerConfig = schema.getDatabaseSchemaProfilerConfig(); + +// Set profiler config +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/databaseSchemaProfilerConfig", + Map.of( + "profileSampleConfig", Map.of( + "sampleConfigType", "STATIC", + "config", Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE") + ), + "sampleDataCount", 200 + ) +); + +// Delete profiler config +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databaseSchemas/" + schemaId + "/databaseSchemaProfilerConfig", + null +); ``` ```bash PUT /v1/databaseSchemas/{id}/followers @@ -142,11 +200,11 @@ curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5 -d '{"updatedVoteType": "unVoted"}' # Get profiler config -curl "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/profilerConfig" \ +curl "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/databaseSchemaProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Set profiler config -curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/profilerConfig" \ +curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/databaseSchemaProfilerConfig" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -161,7 +219,7 @@ curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5 }' # Delete profiler config -curl -X DELETE "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/profilerConfig" \ +curl -X DELETE "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/databaseSchemaProfilerConfig" \ -H "Authorization: Bearer {access_token}" ``` diff --git a/v1.13.x/api-reference/data-assets/database-schemas/create.mdx b/v1.13.x/api-reference/data-assets/database-schemas/create.mdx index aadc7cf93..41ee04af9 100644 --- a/v1.13.x/api-reference/data-assets/database-schemas/create.mdx +++ b/v1.13.x/api-reference/data-assets/database-schemas/create.mdx @@ -28,7 +28,7 @@ Create a new database schema within a database. - Data retention period in ISO 8601 duration format (e.g., `P365D`). + Data retention period in ISO 8601 duration format, for example `P365D`. @@ -40,7 +40,7 @@ Create a new database schema within a database. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -49,8 +49,8 @@ Create a new database schema within a database. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -62,11 +62,11 @@ Create a new database schema within a database. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -95,15 +95,16 @@ request = CreateDatabaseSchemaRequest( ) schema = DatabaseSchemas.create(request) -print(f"Created: {schema.fullyQualifiedName}") +print(f"Created: {schema.fullyQualifiedName.root}") ``` ```java POST /v1/databaseSchemas -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.sdk.fluent.builders.DatabaseSchemaBuilder; -DatabaseSchema schema = DatabaseSchemas.builder() +DatabaseSchema schema = new DatabaseSchemaBuilder(client) .name("public") - .database("snowflake_prod.analytics") + .databaseFQN("snowflake_prod.analytics") .create(); ``` @@ -229,7 +230,7 @@ Returns the created database schema object with all specified properties and sys - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -245,7 +246,7 @@ Returns the created database schema object with all specified properties and sys - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -267,11 +268,11 @@ Returns the created database schema object with all specified properties and sys - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/database-schemas/delete.mdx b/v1.13.x/api-reference/data-assets/database-schemas/delete.mdx index 2cc2da242..ef90c0938 100644 --- a/v1.13.x/api-reference/data-assets/database-schemas/delete.mdx +++ b/v1.13.x/api-reference/data-assets/database-schemas/delete.mdx @@ -28,7 +28,7 @@ Delete a database schema by ID or fully qualified name. Supports soft delete (de Use `DELETE /v1/databaseSchemas/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the schema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the schema, for example `snowflake_prod.analytics.public`. @@ -67,31 +67,28 @@ DatabaseSchemas.delete( hard_delete=True ) -# Delete by name -DatabaseSchemas.delete_by_name("snowflake_prod.analytics.public") +# Delete by name (look up the ID first) +entity = DatabaseSchemas.retrieve_by_name("snowflake_prod.analytics.public") +DatabaseSchemas.delete(entity.id) # Delete by name with options -DatabaseSchemas.delete_by_name( - "snowflake_prod.analytics.public", - recursive=True, - hard_delete=True -) +entity = DatabaseSchemas.retrieve_by_name("snowflake_prod.analytics.public") +DatabaseSchemas.delete(entity.id, recursive=True, hard_delete=True) # Restore a soft-deleted schema DatabaseSchemas.restore("770e8400-e29b-41d4-a716-446655440000") ``` ```java DELETE /v1/databaseSchemas/{id} -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. // Soft delete -DatabaseSchemas.delete("770e8400-e29b-41d4-a716-446655440000").execute(); +client.databaseSchemas().delete("770e8400-e29b-41d4-a716-446655440000"); // Hard delete with recursive -DatabaseSchemas.delete("770e8400-e29b-41d4-a716-446655440000") - .recursive() - .hardDelete() - .execute(); +client.databaseSchemas().delete("770e8400-e29b-41d4-a716-446655440000", Map.of("recursive", "true", "hardDelete", "true")); ``` ```bash DELETE /v1/databaseSchemas/{id} diff --git a/v1.13.x/api-reference/data-assets/database-schemas/import-export.mdx b/v1.13.x/api-reference/data-assets/database-schemas/import-export.mdx index 7c1e7ffe5..a9237a69d 100644 --- a/v1.13.x/api-reference/data-assets/database-schemas/import-export.mdx +++ b/v1.13.x/api-reference/data-assets/database-schemas/import-export.mdx @@ -14,7 +14,7 @@ Export database schema metadata (tables, owners, tags) to CSV and import changes `GET /v1/databaseSchemas/name/{fqn}/export` - Fully qualified name of the schema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the schema, for example `snowflake_prod.analytics.public`. ## Export Async @@ -88,17 +88,19 @@ result = ( ```java GET /v1/databaseSchemas/name/{fqn}/export import org.openmetadata.sdk.fluent.DatabaseSchemas; +DatabaseSchemas.setDefaultClient(client); + // Synchronous export String csvData = DatabaseSchemas.exportCsv("snowflake_prod.analytics.public") .execute(); // Async export -String jobId = DatabaseSchemas.exportCsv("snowflake_prod.analytics.public") +String exportJobId = DatabaseSchemas.exportCsv("snowflake_prod.analytics.public") .async() .execute(); // Synchronous import (dry run) -String result = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") +String dryRunResult = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") .withData(csvData) .dryRun(true) .execute(); @@ -110,7 +112,7 @@ String result = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") .execute(); // Async import -String jobId = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") +String importJobId = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") .withData(csvData) .dryRun(false) .async() diff --git a/v1.13.x/api-reference/data-assets/database-schemas/list.mdx b/v1.13.x/api-reference/data-assets/database-schemas/list.mdx index 3ced4ae73..cace5799f 100644 --- a/v1.13.x/api-reference/data-assets/database-schemas/list.mdx +++ b/v1.13.x/api-reference/data-assets/database-schemas/list.mdx @@ -52,27 +52,32 @@ configure( # List with pagination page = DatabaseSchemas.list(limit=50, fields=["owners", "tags"]) for s in page.entities: - print(f"{s.fullyQualifiedName}") + print(f"{s.fullyQualifiedName.root}") if s.owners: - print(f" Owners: {[o.name for o in s.owners]}") + print(f" Owners: {[o.name for o in s.owners.root]}") # List all with auto-pagination all_schemas = DatabaseSchemas.list_all(batch_size=100) for schema in all_schemas: - print(f"{schema.fullyQualifiedName}") + print(f"{schema.fullyQualifiedName.root}") ``` ```java GET /v1/databaseSchemas -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // Retrieve by ID -DatabaseSchema schema = DatabaseSchemas.retrieve(schemaId); +DatabaseSchema schema = client.databaseSchemas().get(schemaId); // List schemas -var result = DatabaseSchemas.list() - .fields("owners", "tags") - .limit(50) - .execute(); +ListResponse result = client.databaseSchemas().list( + new ListParams() + .setFields("owners,tags") + .setLimit(50) +); for (DatabaseSchema s : result.getData()) { System.out.println(s.getFullyQualifiedName()); @@ -206,7 +211,7 @@ Returns a paginated list of database schema objects. By default, only basic fiel - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v1.13.x/api-reference/data-assets/database-schemas/retrieve.mdx b/v1.13.x/api-reference/data-assets/database-schemas/retrieve.mdx index 5a4efdad7..d2ac7976b 100644 --- a/v1.13.x/api-reference/data-assets/database-schemas/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/database-schemas/retrieve.mdx @@ -28,7 +28,7 @@ Get a single database schema by its unique ID or fully qualified name. Use `GET /v1/databaseSchemas/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the schema (e.g., `Glue.default.information_schema`). + Fully qualified name of the schema, for example `Glue.default.information_schema`. @@ -51,7 +51,7 @@ configure( # Get by ID schema = DatabaseSchemas.retrieve("770e8400-e29b-41d4-a716-446655440000") -print(f"{schema.fullyQualifiedName}: {schema.description}") +print(f"{schema.fullyQualifiedName.root}: {schema.name.root}") # Get by ID with fields schema = DatabaseSchemas.retrieve( @@ -65,18 +65,20 @@ schema = DatabaseSchemas.retrieve_by_name("snowflake_prod.analytics.public") # Get by name with fields schema = DatabaseSchemas.retrieve_by_name( "snowflake_prod.analytics.public", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/databaseSchemas/{id} -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; + +// client is an initialized OpenMetadataClient. // Get by ID -DatabaseSchema schema = DatabaseSchemas.retrieve("770e8400-e29b-41d4-a716-446655440000"); +DatabaseSchema schema = client.databaseSchemas().get("770e8400-e29b-41d4-a716-446655440000"); // Get by fully qualified name -DatabaseSchema schema = DatabaseSchemas.retrieveByName("snowflake_prod.analytics.public"); +DatabaseSchema schemaByName = client.databaseSchemas().getByName("snowflake_prod.analytics.public"); ``` ```bash GET /v1/databaseSchemas/{id} @@ -230,7 +232,7 @@ Returns a database schema object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v1.13.x/api-reference/data-assets/database-schemas/update.mdx b/v1.13.x/api-reference/data-assets/database-schemas/update.mdx index 360f5b1e3..2df2cd726 100644 --- a/v1.13.x/api-reference/data-assets/database-schemas/update.mdx +++ b/v1.13.x/api-reference/data-assets/database-schemas/update.mdx @@ -20,7 +20,7 @@ Update a database schema's properties using JSON Merge Patch. You can update by Use `PATCH /v1/databaseSchemas/name/{fqn}` to update by fully qualified name. - Fully qualified name of the schema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the schema, for example `snowflake_prod.analytics.public`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,11 +58,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -71,8 +71,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. Updated retention period in ISO 8601 duration format. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -95,16 +95,18 @@ schema.description = "Updated public schema for analytics" schema.retentionPeriod = "P730D" updated = DatabaseSchemas.update(schema) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/databaseSchemas/{id} -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -DatabaseSchema schema = DatabaseSchemas.retrieve("770e8400-e29b-41d4-a716-446655440000"); +DatabaseSchema schema = client.databaseSchemas().get("770e8400-e29b-41d4-a716-446655440000"); schema.setDescription("Updated public schema for analytics"); -DatabaseSchema updated = DatabaseSchemas.update(schema); +DatabaseSchema updated = client.databaseSchemas().update("770e8400-e29b-41d4-a716-446655440000", schema); ``` ```bash PATCH /v1/databaseSchemas/{id} diff --git a/v1.13.x/api-reference/data-assets/database-schemas/versions.mdx b/v1.13.x/api-reference/data-assets/database-schemas/versions.mdx index 076951d20..57d2608eb 100644 --- a/v1.13.x/api-reference/data-assets/database-schemas/versions.mdx +++ b/v1.13.x/api-reference/data-assets/database-schemas/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/databaseSchemas/{id}/versions/{version}` to retrieve a specific ver - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/databaseSchemas/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import DatabaseSchemas @@ -40,26 +42,30 @@ configure( # List all versions versions = DatabaseSchemas.get_versions("770e8400-e29b-41d4-a716-446655440000") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version schema_v1 = DatabaseSchemas.get_specific_version( "770e8400-e29b-41d4-a716-446655440000", "0.1" ) -print(f"Original description: {schema_v1.description}") +print(f"Original description: {schema_v1.description.root if schema_v1.description else None}") ``` ```java GET /v1/databaseSchemas/{id}/versions -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = DatabaseSchemas.getVersions("770e8400-e29b-41d4-a716-446655440000"); +EntityHistory versions = client.databaseSchemas().getVersionList("770e8400-e29b-41d4-a716-446655440000"); // Get a specific version -DatabaseSchema v1 = DatabaseSchemas.getSpecificVersion( +DatabaseSchema v1 = client.databaseSchemas().getVersion( "770e8400-e29b-41d4-a716-446655440000", - "0.1" + 0.1 ); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/database-services/create.mdx b/v1.13.x/api-reference/data-assets/database-services/create.mdx index 06a17eafe..a6fff33ee 100644 --- a/v1.13.x/api-reference/data-assets/database-services/create.mdx +++ b/v1.13.x/api-reference/data-assets/database-services/create.mdx @@ -16,7 +16,7 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Type of database service (e.g., `Snowflake`, `BigQuery`, `PostgreSQL`, `MySQL`, `Redshift`, `Databricks`). + Type of database service, for example `Snowflake`, `BigQuery`, `PostgreSQL`, `MySQL`, `Redshift`, `Databricks`. @@ -32,7 +32,7 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Service-specific connection configuration (e.g., account, warehouse, database for Snowflake). + Service-specific connection configuration, for example account, warehouse, database for Snowflake. @@ -46,7 +46,7 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new database service connection to a platform such as Snowflake, BigQue - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -105,21 +105,30 @@ request = CreateDatabaseServiceRequest( ) service = DatabaseServices.create(request) -print(f"Created: {service.fullyQualifiedName}") +print(f"Created: {service.fullyQualifiedName.root}") ``` ```java POST /v1/services/databaseServices -import static org.openmetadata.sdk.fluent.DatabaseServices.*; - -DatabaseService service = DatabaseServices.builder() - .name("snowflake_prod") - .serviceType("Snowflake") - .connection(snowflakeConnection() - .account("xy12345.us-east-1") - .username("ingestion_user") - .warehouse("COMPUTE_WH") - .database("ANALYTICS")) - .create(); +import org.openmetadata.schema.api.services.CreateDatabaseService; +import org.openmetadata.schema.api.services.CreateDatabaseService.DatabaseServiceType; +import org.openmetadata.schema.api.services.DatabaseConnection; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.services.connections.database.SnowflakeConnection; +import org.openmetadata.sdk.fluent.DatabaseServices; + +CreateDatabaseService request = new CreateDatabaseService() + .withName("snowflake_prod") + .withServiceType(DatabaseServiceType.Snowflake) + .withDescription("Production Snowflake data warehouse") + .withConnection(new DatabaseConnection().withConfig( + new SnowflakeConnection() + .withAccount("xy12345.us-east-1") + .withUsername("ingestion_user") + .withPassword("***") + .withWarehouse("COMPUTE_WH") + .withDatabase("ANALYTICS"))); + +DatabaseService service = DatabaseServices.create(request); ``` ```bash POST /v1/services/databaseServices @@ -215,7 +224,7 @@ Returns the created database service object with all specified properties and sy - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -237,7 +246,7 @@ Returns the created database service object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -246,7 +255,7 @@ Returns the created database service object with all specified properties and sy - + Fully qualified name of the assigned domain. @@ -259,11 +268,11 @@ Returns the created database service object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/database-services/delete.mdx b/v1.13.x/api-reference/data-assets/database-services/delete.mdx index 771abdd2d..0c1aee2b1 100644 --- a/v1.13.x/api-reference/data-assets/database-services/delete.mdx +++ b/v1.13.x/api-reference/data-assets/database-services/delete.mdx @@ -28,7 +28,7 @@ Delete a database service by ID or fully qualified name. Supports soft delete (d Use `DELETE /v1/services/databaseServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. @@ -68,11 +68,11 @@ DatabaseServices.delete( ) # Delete by name -DatabaseServices.delete_by_name("snowflake_prod") +DatabaseServices.delete(DatabaseServices.retrieve_by_name("snowflake_prod").id) # Delete by name with options -DatabaseServices.delete_by_name( - "snowflake_prod", +DatabaseServices.delete( + DatabaseServices.retrieve_by_name("snowflake_prod").id, recursive=True, hard_delete=True ) @@ -82,7 +82,8 @@ DatabaseServices.restore("a1b2c3d4-e5f6-7890-abcd-ef1234567890") ``` ```java DELETE /v1/services/databaseServices/{id} -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.fluent.DatabaseServices; // Soft delete DatabaseServices.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890").execute(); diff --git a/v1.13.x/api-reference/data-assets/database-services/import-export.mdx b/v1.13.x/api-reference/data-assets/database-services/import-export.mdx index bfff3024c..925f07e5a 100644 --- a/v1.13.x/api-reference/data-assets/database-services/import-export.mdx +++ b/v1.13.x/api-reference/data-assets/database-services/import-export.mdx @@ -14,7 +14,7 @@ Export database service metadata (databases, schemas, owners, tags) to CSV and i `GET /v1/services/databaseServices/name/{fqn}/export` - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. ## Export Async @@ -86,35 +86,21 @@ result = ( ``` ```java GET /v1/services/databaseServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.DatabaseServices; - +// client is an initialized OpenMetadataClient. // Synchronous export -String csvData = DatabaseServices.exportCsv("snowflake_prod") - .execute(); +String csvData = client.databaseServices().exportCsv("snowflake_prod"); // Async export -String jobId = DatabaseServices.exportCsv("snowflake_prod") - .async() - .execute(); - -// Synchronous import (dry run) -String result = DatabaseServices.importCsv("snowflake_prod") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = DatabaseServices.importCsv("snowflake_prod") - .withData(csvData) - .dryRun(false) - .execute(); +String exportJob = client.databaseServices().exportCsvAsync("snowflake_prod"); + +// Import CSV (dry run first) +String dryRunResult = client.databaseServices().importCsv("snowflake_prod", csvData, true); + +// Apply the import +String result = client.databaseServices().importCsv("snowflake_prod", csvData, false); // Async import -String jobId = DatabaseServices.importCsv("snowflake_prod") - .withData(csvData) - .dryRun(false) - .async() - .execute(); +String importJob = client.databaseServices().importCsvAsync("snowflake_prod", csvData, false); ``` ```bash GET /v1/services/databaseServices/name/{fqn}/export diff --git a/v1.13.x/api-reference/data-assets/database-services/list.mdx b/v1.13.x/api-reference/data-assets/database-services/list.mdx index 5317ead18..305fe5109 100644 --- a/v1.13.x/api-reference/data-assets/database-services/list.mdx +++ b/v1.13.x/api-reference/data-assets/database-services/list.mdx @@ -48,31 +48,34 @@ configure( # List with pagination page = DatabaseServices.list(limit=50, fields=["owners", "tags"]) for svc in page.entities: - print(f"{svc.name} ({svc.serviceType})") + print(f"{svc.name.root} ({svc.serviceType})") if svc.owners: - print(f" Owners: {[o.name for o in svc.owners]}") + print(f" Owners: {[o.name for o in svc.owners.root]}") # List all with auto-pagination all_services = DatabaseServices.list_all(batch_size=100) for service in all_services: - print(f"{service.fullyQualifiedName}") + print(f"{service.fullyQualifiedName.root}") ``` ```java GET /v1/services/databaseServices -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; -// Retrieve by ID -DatabaseService service = DatabaseServices.retrieve(serviceId); +// client is an initialized OpenMetadataClient. -// List services -var result = DatabaseServices.list() - .fields("owners", "tags") - .limit(50) - .execute(); +// List first page +ListResponse firstPage = client.databaseServices().list(new ListParams().setLimit(50)); -for (DatabaseService svc : result.getData()) { - System.out.println(svc.getName() + " (" + svc.getServiceType() + ")"); +for (DatabaseService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } + +// With fields +ListResponse withFields = client.databaseServices().list( + new ListParams().setFields("owners,tags").setLimit(50) +); ``` ```bash GET /v1/services/databaseServices @@ -190,7 +193,7 @@ Returns a paginated list of database service objects. By default, only basic fie - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v1.13.x/api-reference/data-assets/database-services/retrieve.mdx b/v1.13.x/api-reference/data-assets/database-services/retrieve.mdx index 316fc13df..95fafb2cb 100644 --- a/v1.13.x/api-reference/data-assets/database-services/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/database-services/retrieve.mdx @@ -28,7 +28,7 @@ Get a single database service by its unique ID or fully qualified name. Use `GET /v1/services/databaseServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. @@ -51,7 +51,7 @@ configure( # Get by ID service = DatabaseServices.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890") -print(f"{service.fullyQualifiedName}: {service.serviceType}") +print(f"{service.fullyQualifiedName.root}: {service.serviceType}") # Get by ID with fields service = DatabaseServices.retrieve( @@ -65,18 +65,19 @@ service = DatabaseServices.retrieve_by_name("snowflake_prod") # Get by name with fields service = DatabaseServices.retrieve_by_name( "snowflake_prod", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/services/databaseServices/{id} -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.fluent.DatabaseServices; // Get by ID DatabaseService service = DatabaseServices.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Get by fully qualified name -DatabaseService service = DatabaseServices.retrieveByName("snowflake_prod"); +DatabaseService serviceByName = DatabaseServices.retrieveByName("snowflake_prod"); ``` ```bash GET /v1/services/databaseServices/{id} @@ -164,7 +165,7 @@ Returns a database service object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v1.13.x/api-reference/data-assets/database-services/update.mdx b/v1.13.x/api-reference/data-assets/database-services/update.mdx index 73829e8da..2a40b5461 100644 --- a/v1.13.x/api-reference/data-assets/database-services/update.mdx +++ b/v1.13.x/api-reference/data-assets/database-services/update.mdx @@ -20,7 +20,7 @@ Update a database service's properties using JSON Merge Patch. You can update by Use `PATCH /v1/services/databaseServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -97,11 +97,12 @@ service.description = "Updated production Snowflake warehouse" service.displayName = "Snowflake Prod (Updated)" updated = DatabaseServices.update(service) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/services/databaseServices/{id} -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.fluent.DatabaseServices; // Retrieve, modify, and update DatabaseService service = DatabaseServices.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); diff --git a/v1.13.x/api-reference/data-assets/database-services/versions.mdx b/v1.13.x/api-reference/data-assets/database-services/versions.mdx index e41aabe1b..ee1510466 100644 --- a/v1.13.x/api-reference/data-assets/database-services/versions.mdx +++ b/v1.13.x/api-reference/data-assets/database-services/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/services/databaseServices/{id}/versions/{version}` to retrieve a sp - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/services/databaseServices/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import DatabaseServices @@ -40,27 +42,32 @@ configure( # List all versions versions = DatabaseServices.get_versions("a1b2c3d4-e5f6-7890-abcd-ef1234567890") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version service_v1 = DatabaseServices.get_specific_version( "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "0.1" ) -print(f"Original description: {service_v1.description}") +print(f"Original description: {getattr(service_v1.description, 'root', service_v1.description)}") ``` ```java GET /v1/services/databaseServices/{id}/versions -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = DatabaseServices.getVersions("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +EntityHistory history = client.databaseServices().getVersionList("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); + +for (Object version : history.getVersions()) { + System.out.println("Version: " + version); +} // Get a specific version -DatabaseService v1 = DatabaseServices.getSpecificVersion( - "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "0.1" -); +DatabaseService v1 = client.databaseServices().getVersion("a1b2c3d4-e5f6-7890-abcd-ef1234567890", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/databases/advanced.mdx b/v1.13.x/api-reference/data-assets/databases/advanced.mdx index 9ae3b3f51..3f9bef554 100644 --- a/v1.13.x/api-reference/data-assets/databases/advanced.mdx +++ b/v1.13.x/api-reference/data-assets/databases/advanced.mdx @@ -53,19 +53,19 @@ Manage followers, votes, and profiler configuration for database entities. ### Get Profiler Config -`GET /v1/databases/{id}/profilerConfig` +`GET /v1/databases/{id}/databaseProfilerConfig` ### Set Profiler Config -`PUT /v1/databases/{id}/profilerConfig` +`PUT /v1/databases/{id}/databaseProfilerConfig` ### Delete Profiler Config -`DELETE /v1/databases/{id}/profilerConfig` +`DELETE /v1/databases/{id}/databaseProfilerConfig` ```python PUT /v1/databases/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Databases configure( @@ -73,27 +73,30 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + database_id = "550e8400-e29b-41d4-a716-446655440000" user_id = "user-uuid-here" # Add a follower database = Databases.add_followers(database_id, [user_id]) -print(f"Followers: {len(database.followers)}") +print(f"Followers: {len(database.followers.root)}") # Remove a follower database = Databases.remove_followers(database_id, [user_id]) # Add a vote -database = Databases.add_vote(database_id, vote_type="votedUp") +rest.put(f"/databases/{database_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -database = Databases.remove_vote(database_id) +rest.put(f"/databases/{database_id}/vote", json={"updatedVoteType": "unVoted"}) # Get profiler config -config = Databases.get_profiler_config(database_id) +database = Databases.retrieve(database_id, fields=["databaseProfilerConfig"]) +print(database.databaseProfilerConfig) # Set profiler config -Databases.set_profiler_config(database_id, { +rest.put(f"/databases/{database_id}/databaseProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": { @@ -105,17 +108,72 @@ Databases.set_profiler_config(database_id, { }) # Delete profiler config -Databases.delete_profiler_config(database_id) +rest.delete(f"/databases/{database_id}/databaseProfilerConfig") ``` ```java PUT /v1/databases/{id}/followers -import static org.openmetadata.sdk.fluent.Databases.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.schema.type.DatabaseProfilerConfig; +import org.openmetadata.sdk.network.HttpMethod; -String databaseId = "550e8400-e29b-41d4-a716-446655440000"; +// client is an initialized OpenMetadataClient. -// Followers - use REST client directly -// Votes and profiler config - use REST client directly -// See curl examples for request format +String databaseId = "550e8400-e29b-41d4-a716-446655440000"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; + +// Add a follower +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/followers", + UUID.fromString(userId) +); + +// Remove a follower +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databases/" + databaseId + "/followers/" + userId, + null +); + +// Add a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/vote", + Map.of("updatedVoteType", "votedUp") +); + +// Remove a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/vote", + Map.of("updatedVoteType", "unVoted") +); + +// Get profiler config +Database database = client.databases().get(databaseId, "databaseProfilerConfig"); +DatabaseProfilerConfig profilerConfig = database.getDatabaseProfilerConfig(); + +// Set profiler config +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/databaseProfilerConfig", + Map.of( + "profileSampleConfig", Map.of( + "sampleConfigType", "STATIC", + "config", Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE") + ), + "sampleDataCount", 200 + ) +); + +// Delete profiler config +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databases/" + databaseId + "/databaseProfilerConfig", + null +); ``` ```bash PUT /v1/databases/{id}/followers @@ -142,11 +200,11 @@ curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/vo -d '{"updatedVoteType": "unVoted"}' # Get profiler config -curl "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/profilerConfig" \ +curl "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/databaseProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Set profiler config -curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/profilerConfig" \ +curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/databaseProfilerConfig" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -161,7 +219,7 @@ curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/pr }' # Delete profiler config -curl -X DELETE "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/profilerConfig" \ +curl -X DELETE "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/databaseProfilerConfig" \ -H "Authorization: Bearer {access_token}" ``` diff --git a/v1.13.x/api-reference/data-assets/databases/create.mdx b/v1.13.x/api-reference/data-assets/databases/create.mdx index 104e9d412..a7bf8dbb5 100644 --- a/v1.13.x/api-reference/data-assets/databases/create.mdx +++ b/v1.13.x/api-reference/data-assets/databases/create.mdx @@ -28,7 +28,7 @@ Create a new database within a database service. - Data retention period in ISO 8601 duration format (e.g., `P365D`). + Data retention period in ISO 8601 duration format, for example `P365D`. @@ -40,7 +40,7 @@ Create a new database within a database service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -49,8 +49,8 @@ Create a new database within a database service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -62,11 +62,11 @@ Create a new database within a database service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -95,15 +95,16 @@ request = CreateDatabaseRequest( ) database = Databases.create(request) -print(f"Created: {database.fullyQualifiedName}") +print(f"Created: {database.fullyQualifiedName.root}") ``` ```java POST /v1/databases -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.sdk.fluent.builders.DatabaseBuilder; -Database database = Databases.builder() +Database database = new DatabaseBuilder(client) .name("analytics") - .service("snowflake_prod") + .serviceFQN("snowflake_prod") .create(); ``` @@ -201,7 +202,7 @@ Returns the created database object with all specified properties and system-gen - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -217,7 +218,7 @@ Returns the created database object with all specified properties and system-gen - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -226,7 +227,7 @@ Returns the created database object with all specified properties and system-gen - + Fully qualified name of the assigned domain. @@ -239,11 +240,11 @@ Returns the created database object with all specified properties and system-gen - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/databases/delete.mdx b/v1.13.x/api-reference/data-assets/databases/delete.mdx index d001ebc97..6078b6c5a 100644 --- a/v1.13.x/api-reference/data-assets/databases/delete.mdx +++ b/v1.13.x/api-reference/data-assets/databases/delete.mdx @@ -28,7 +28,7 @@ Delete a database by ID or fully qualified name. Supports soft delete (default), Use `DELETE /v1/databases/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the database (e.g., `snowflake_prod.analytics`). + Fully qualified name of the database, for example `snowflake_prod.analytics`. @@ -67,31 +67,28 @@ Databases.delete( hard_delete=True ) -# Delete by name -Databases.delete_by_name("snowflake_prod.analytics") +# Delete by name (look up the ID first) +entity = Databases.retrieve_by_name("snowflake_prod.analytics") +Databases.delete(entity.id) # Delete by name with options -Databases.delete_by_name( - "snowflake_prod.analytics", - recursive=True, - hard_delete=True -) +entity = Databases.retrieve_by_name("snowflake_prod.analytics") +Databases.delete(entity.id, recursive=True, hard_delete=True) # Restore a soft-deleted database Databases.restore("550e8400-e29b-41d4-a716-446655440000") ``` ```java DELETE /v1/databases/{id} -import static org.openmetadata.sdk.fluent.Databases.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. // Soft delete -Databases.delete("550e8400-e29b-41d4-a716-446655440000").execute(); +client.databases().delete("550e8400-e29b-41d4-a716-446655440000"); // Hard delete with recursive -Databases.delete("550e8400-e29b-41d4-a716-446655440000") - .recursive() - .hardDelete() - .execute(); +client.databases().delete("550e8400-e29b-41d4-a716-446655440000", Map.of("recursive", "true", "hardDelete", "true")); ``` ```bash DELETE /v1/databases/{id} diff --git a/v1.13.x/api-reference/data-assets/databases/import-export.mdx b/v1.13.x/api-reference/data-assets/databases/import-export.mdx index afd59678e..ce6cc0dbd 100644 --- a/v1.13.x/api-reference/data-assets/databases/import-export.mdx +++ b/v1.13.x/api-reference/data-assets/databases/import-export.mdx @@ -14,7 +14,7 @@ Export database metadata (schemas, tables, owners, tags) to CSV and import chang `GET /v1/databases/name/{fqn}/export` - Fully qualified name of the database (e.g., `snowflake_prod.analytics`). + Fully qualified name of the database, for example `snowflake_prod.analytics`. ## Export Async @@ -88,17 +88,19 @@ result = ( ```java GET /v1/databases/name/{fqn}/export import org.openmetadata.sdk.fluent.Databases; +Databases.setDefaultClient(client); + // Synchronous export String csvData = Databases.exportCsv("snowflake_prod.analytics") .execute(); // Async export -String jobId = Databases.exportCsv("snowflake_prod.analytics") +String exportJobId = Databases.exportCsv("snowflake_prod.analytics") .async() .execute(); // Synchronous import (dry run) -String result = Databases.importCsv("snowflake_prod.analytics") +String dryRunResult = Databases.importCsv("snowflake_prod.analytics") .withData(csvData) .dryRun(true) .execute(); @@ -110,7 +112,7 @@ String result = Databases.importCsv("snowflake_prod.analytics") .execute(); // Async import -String jobId = Databases.importCsv("snowflake_prod.analytics") +String importJobId = Databases.importCsv("snowflake_prod.analytics") .withData(csvData) .dryRun(false) .async() diff --git a/v1.13.x/api-reference/data-assets/databases/list.mdx b/v1.13.x/api-reference/data-assets/databases/list.mdx index 4fd9170c0..34ca00f2f 100644 --- a/v1.13.x/api-reference/data-assets/databases/list.mdx +++ b/v1.13.x/api-reference/data-assets/databases/list.mdx @@ -52,27 +52,32 @@ configure( # List with pagination page = Databases.list(limit=50, fields=["owners", "tags"]) for db in page.entities: - print(f"{db.fullyQualifiedName}") + print(f"{db.fullyQualifiedName.root}") if db.owners: - print(f" Owners: {[o.name for o in db.owners]}") + print(f" Owners: {[o.name for o in db.owners.root]}") # List all with auto-pagination all_databases = Databases.list_all(batch_size=100) for database in all_databases: - print(f"{database.fullyQualifiedName}") + print(f"{database.fullyQualifiedName.root}") ``` ```java GET /v1/databases -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // Retrieve by ID -Database database = Databases.retrieve(databaseId); +Database database = client.databases().get(databaseId); // List databases -var result = Databases.list() - .fields("owners", "tags") - .limit(50) - .execute(); +ListResponse result = client.databases().list( + new ListParams() + .setFields("owners,tags") + .setLimit(50) +); for (Database db : result.getData()) { System.out.println(db.getFullyQualifiedName()); @@ -181,7 +186,7 @@ Returns a paginated list of database objects. By default, only basic fields are - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -192,8 +197,8 @@ Returns a paginated list of database objects. By default, only basic fields are Classification tags applied to the database. Only included when `fields` contains `tags`. - - Domain assignment for governance. Only included when `fields` contains `domain`. + + Domain assignment for governance. Only included when `fields` contains `domains`. diff --git a/v1.13.x/api-reference/data-assets/databases/retrieve.mdx b/v1.13.x/api-reference/data-assets/databases/retrieve.mdx index 06132894b..75a554830 100644 --- a/v1.13.x/api-reference/data-assets/databases/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/databases/retrieve.mdx @@ -28,7 +28,7 @@ Get a single database by its unique ID or fully qualified name. Use `GET /v1/databases/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the database (e.g., `mysql_sample.default`). + Fully qualified name of the database, for example `mysql_sample.default`. @@ -51,7 +51,7 @@ configure( # Get by ID database = Databases.retrieve("550e8400-e29b-41d4-a716-446655440000") -print(f"{database.fullyQualifiedName}: {database.description}") +print(f"{database.fullyQualifiedName.root}: {database.name.root}") # Get by ID with fields database = Databases.retrieve( @@ -65,18 +65,20 @@ database = Databases.retrieve_by_name("snowflake_prod.analytics") # Get by name with fields database = Databases.retrieve_by_name( "snowflake_prod.analytics", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/databases/{id} -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; + +// client is an initialized OpenMetadataClient. // Get by ID -Database database = Databases.retrieve("550e8400-e29b-41d4-a716-446655440000"); +Database database = client.databases().get("550e8400-e29b-41d4-a716-446655440000"); // Get by fully qualified name -Database database = Databases.retrieveByName("snowflake_prod.analytics"); +Database databaseByName = client.databases().getByName("snowflake_prod.analytics"); ``` ```bash GET /v1/databases/{id} @@ -187,7 +189,7 @@ Returns a database object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -202,8 +204,8 @@ Returns a database object with all requested fields populated. Classification tags. Only included when `fields` contains `tags`. - - Domain assignment. Only included when `fields` contains `domain`. + + Domain assignment. Only included when `fields` contains `domains`. --- diff --git a/v1.13.x/api-reference/data-assets/databases/update.mdx b/v1.13.x/api-reference/data-assets/databases/update.mdx index 2c1492a8b..a18ad7e83 100644 --- a/v1.13.x/api-reference/data-assets/databases/update.mdx +++ b/v1.13.x/api-reference/data-assets/databases/update.mdx @@ -20,7 +20,7 @@ Update a database's properties using JSON Merge Patch. You can update by ID or b Use `PATCH /v1/databases/name/{fqn}` to update by fully qualified name. - Fully qualified name of the database (e.g., `snowflake_prod.analytics`). + Fully qualified name of the database, for example `snowflake_prod.analytics`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,11 +58,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -71,8 +71,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. Updated retention period in ISO 8601 duration format. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -95,16 +95,18 @@ database.description = "Updated analytics data warehouse" database.retentionPeriod = "P730D" updated = Databases.update(database) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/databases/{id} -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -Database database = Databases.retrieve("550e8400-e29b-41d4-a716-446655440000"); +Database database = client.databases().get("550e8400-e29b-41d4-a716-446655440000"); database.setDescription("Updated analytics data warehouse"); -Database updated = Databases.update(database); +Database updated = client.databases().update("550e8400-e29b-41d4-a716-446655440000", database); ``` ```bash PATCH /v1/databases/{id} diff --git a/v1.13.x/api-reference/data-assets/databases/versions.mdx b/v1.13.x/api-reference/data-assets/databases/versions.mdx index 536c721ce..af377eff8 100644 --- a/v1.13.x/api-reference/data-assets/databases/versions.mdx +++ b/v1.13.x/api-reference/data-assets/databases/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/databases/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/databases/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Databases @@ -40,26 +42,30 @@ configure( # List all versions versions = Databases.get_versions("550e8400-e29b-41d4-a716-446655440000") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version database_v1 = Databases.get_specific_version( "550e8400-e29b-41d4-a716-446655440000", "0.1" ) -print(f"Original description: {database_v1.description}") +print(f"Original description: {database_v1.description.root if database_v1.description else None}") ``` ```java GET /v1/databases/{id}/versions -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = Databases.getVersions("550e8400-e29b-41d4-a716-446655440000"); +EntityHistory versions = client.databases().getVersionList("550e8400-e29b-41d4-a716-446655440000"); // Get a specific version -Database v1 = Databases.getSpecificVersion( +Database v1 = client.databases().getVersion( "550e8400-e29b-41d4-a716-446655440000", - "0.1" + 0.1 ); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/messaging-services/create.mdx b/v1.13.x/api-reference/data-assets/messaging-services/create.mdx index 96bf6dabf..74298f429 100644 --- a/v1.13.x/api-reference/data-assets/messaging-services/create.mdx +++ b/v1.13.x/api-reference/data-assets/messaging-services/create.mdx @@ -16,7 +16,7 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Type of messaging service (e.g., `Kafka`, `Redpanda`, `Kinesis`, `CustomMessaging`). + Type of messaging service, for example `Kafka`, `Redpanda`, `Kinesis`, `CustomMessaging`. @@ -32,7 +32,7 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Service-specific connection configuration (e.g., bootstrapServers, securityProtocol for Kafka). + Service-specific connection configuration, for example bootstrapServers, securityProtocol for Kafka. @@ -46,7 +46,7 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -114,16 +114,22 @@ print(f"Created: {service['fullyQualifiedName']}") ``` ```java POST /v1/services/messagingServices -import static org.openmetadata.sdk.fluent.MessagingServices.*; - -MessagingService service = MessagingServices.builder() - .name("sample_kafka") - .serviceType("Kafka") - .connection(kafkaConnection() - .bootstrapServers("localhost:9092") - .securityProtocol("PLAINTEXT") - .saslMechanism("PLAIN")) - .create(); +import org.openmetadata.schema.api.services.CreateMessagingService; +import org.openmetadata.schema.api.services.CreateMessagingService.MessagingServiceType; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.schema.services.connections.messaging.KafkaConnection; +import org.openmetadata.schema.type.MessagingConnection; +import org.openmetadata.sdk.fluent.MessagingServices; + +CreateMessagingService request = new CreateMessagingService() + .withName("sample_kafka") + .withServiceType(MessagingServiceType.Kafka) + .withConnection(new MessagingConnection().withConfig( + new KafkaConnection() + .withBootstrapServers("localhost:9092") + .withSecurityProtocol(KafkaConnection.SecurityProtocol.PLAINTEXT))); + +MessagingService service = MessagingServices.create(request); ``` ```bash POST /v1/services/messagingServices @@ -206,7 +212,7 @@ Returns the created messaging service object with all specified properties and s - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. @@ -228,7 +234,7 @@ Returns the created messaging service object with all specified properties and s - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -237,7 +243,7 @@ Returns the created messaging service object with all specified properties and s - + Fully qualified name of the assigned domain. @@ -250,11 +256,11 @@ Returns the created messaging service object with all specified properties and s - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/messaging-services/delete.mdx b/v1.13.x/api-reference/data-assets/messaging-services/delete.mdx index c7a4bffb5..8310eaed0 100644 --- a/v1.13.x/api-reference/data-assets/messaging-services/delete.mdx +++ b/v1.13.x/api-reference/data-assets/messaging-services/delete.mdx @@ -28,7 +28,7 @@ Delete a messaging service by ID or fully qualified name. Supports soft delete ( Use `DELETE /v1/services/messagingServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. @@ -82,7 +82,8 @@ requests.put( ``` ```java DELETE /v1/services/messagingServices/{id} -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.fluent.MessagingServices; // Soft delete MessagingServices.delete("469ef25e-9bdf-4d5f-8553-eb0ce8581f30").execute(); diff --git a/v1.13.x/api-reference/data-assets/messaging-services/import-export.mdx b/v1.13.x/api-reference/data-assets/messaging-services/import-export.mdx index df1aadd09..58a7b937c 100644 --- a/v1.13.x/api-reference/data-assets/messaging-services/import-export.mdx +++ b/v1.13.x/api-reference/data-assets/messaging-services/import-export.mdx @@ -14,7 +14,7 @@ Export messaging service metadata (topics, owners, tags) to CSV and import chang `GET /v1/services/messagingServices/name/{fqn}/export` - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. ## Export Async @@ -90,38 +90,6 @@ response = requests.put( ) ``` -```java GET /v1/services/messagingServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.MessagingServices; - -// Synchronous export -String csvData = MessagingServices.exportCsv("sample_kafka") - .execute(); - -// Async export -String jobId = MessagingServices.exportCsv("sample_kafka") - .async() - .execute(); - -// Synchronous import (dry run) -String result = MessagingServices.importCsv("sample_kafka") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = MessagingServices.importCsv("sample_kafka") - .withData(csvData) - .dryRun(false) - .execute(); - -// Async import -String jobId = MessagingServices.importCsv("sample_kafka") - .withData(csvData) - .dryRun(false) - .async() - .execute(); -``` - ```bash GET /v1/services/messagingServices/name/{fqn}/export # Export to CSV curl "{base_url}/api/v1/services/messagingServices/name/sample_kafka/export" \ diff --git a/v1.13.x/api-reference/data-assets/messaging-services/list.mdx b/v1.13.x/api-reference/data-assets/messaging-services/list.mdx index a6d62e380..0595a9ead 100644 --- a/v1.13.x/api-reference/data-assets/messaging-services/list.mdx +++ b/v1.13.x/api-reference/data-assets/messaging-services/list.mdx @@ -61,17 +61,23 @@ response = requests.get( ``` ```java GET /v1/services/messagingServices -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; -// List services -var result = MessagingServices.list() - .fields("owners", "tags") - .limit(50) - .execute(); +// client is an initialized OpenMetadataClient. -for (MessagingService svc : result.getData()) { - System.out.println(svc.getName() + " (" + svc.getServiceType() + ")"); +// List first page +ListResponse firstPage = client.messagingServices().list(new ListParams().setLimit(50)); + +for (MessagingService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } + +// With fields +ListResponse withFields = client.messagingServices().list( + new ListParams().setFields("owners,tags").setLimit(50) +); ``` ```bash GET /v1/services/messagingServices @@ -155,7 +161,7 @@ Returns a paginated list of messaging service objects. By default, only basic fi - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v1.13.x/api-reference/data-assets/messaging-services/retrieve.mdx b/v1.13.x/api-reference/data-assets/messaging-services/retrieve.mdx index 8a164f3f8..eb445df61 100644 --- a/v1.13.x/api-reference/data-assets/messaging-services/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/messaging-services/retrieve.mdx @@ -28,7 +28,7 @@ Get a single messaging service by its unique ID or fully qualified name. Use `GET /v1/services/messagingServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. @@ -76,13 +76,23 @@ response = requests.get( ``` ```java GET /v1/services/messagingServices/{id} -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.fluent.MessagingServices; // Get by ID MessagingService service = MessagingServices.retrieve("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); +// Get by ID with fields +MessagingService serviceWithFields = MessagingServices.retrieve( + "469ef25e-9bdf-4d5f-8553-eb0ce8581f30", + "owners,tags" +); + // Get by fully qualified name -MessagingService service = MessagingServices.retrieveByName("sample_kafka"); +MessagingService serviceByName = MessagingServices.retrieveByName("sample_kafka"); + +// Get by name with fields +MessagingService serviceByNameWithFields = MessagingServices.retrieveByName("sample_kafka", "owners,tags"); ``` ```bash GET /v1/services/messagingServices/{id} @@ -162,7 +172,7 @@ Returns a messaging service object with all requested fields populated. - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v1.13.x/api-reference/data-assets/messaging-services/update.mdx b/v1.13.x/api-reference/data-assets/messaging-services/update.mdx index 5cd79add9..13b894550 100644 --- a/v1.13.x/api-reference/data-assets/messaging-services/update.mdx +++ b/v1.13.x/api-reference/data-assets/messaging-services/update.mdx @@ -20,7 +20,7 @@ Update a messaging service's properties using JSON Merge Patch. You can update b Use `PATCH /v1/services/messagingServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -105,7 +105,8 @@ print(f"Updated to version {updated['version']}") ``` ```java PATCH /v1/services/messagingServices/{id} -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.fluent.MessagingServices; // Retrieve, modify, and update MessagingService service = MessagingServices.retrieve("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); diff --git a/v1.13.x/api-reference/data-assets/messaging-services/versions.mdx b/v1.13.x/api-reference/data-assets/messaging-services/versions.mdx index 59bd8e175..80c748e35 100644 --- a/v1.13.x/api-reference/data-assets/messaging-services/versions.mdx +++ b/v1.13.x/api-reference/data-assets/messaging-services/versions.mdx @@ -24,7 +24,7 @@ Use `GET /v1/services/messagingServices/{id}/versions/{version}` to retrieve a s - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. @@ -53,16 +53,20 @@ print(f"Original description: {service_v1.get('description')}") ``` ```java GET /v1/services/messagingServices/{id}/versions -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = MessagingServices.getVersions("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); +EntityHistory history = client.messagingServices().getVersionList("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); + +for (Object version : history.getVersions()) { + System.out.println("Version: " + version); +} // Get a specific version -MessagingService v1 = MessagingServices.getSpecificVersion( - "469ef25e-9bdf-4d5f-8553-eb0ce8581f30", - "0.1" -); +MessagingService v1 = client.messagingServices().getVersion("469ef25e-9bdf-4d5f-8553-eb0ce8581f30", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/mlmodel-services/create.mdx b/v1.13.x/api-reference/data-assets/mlmodel-services/create.mdx index 096cf9df1..b01d04484 100644 --- a/v1.13.x/api-reference/data-assets/mlmodel-services/create.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodel-services/create.mdx @@ -16,7 +16,7 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Type of ML model service (e.g., `Mlflow`, `Sklearn`, `SageMaker`, `CustomMlModel`). + Type of ML model service, for example `Mlflow`, `Sklearn`, `SageMaker`, `CustomMlModel`. @@ -24,7 +24,7 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Service-specific connection configuration (e.g., `trackingUri`, `registryUri` for Mlflow). + Service-specific connection configuration, for example `trackingUri`, `registryUri` for Mlflow. @@ -46,7 +46,7 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,24 +68,33 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. ```python POST /v1/services/mlmodelServices -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.generated.schema.api.services.createMlModelService import CreateMlModelServiceRequest -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) request = CreateMlModelServiceRequest( @@ -103,20 +112,27 @@ request = CreateMlModelServiceRequest( } ) -service = MlModelServices.create(request) -print(f"Created: {service.fullyQualifiedName}") +service = metadata.create_or_update(request) +print(f"Created: {service.fullyQualifiedName.root}") ``` ```java POST /v1/services/mlmodelServices -import static org.openmetadata.sdk.fluent.MlModelServices.*; - -MlModelService service = MlModelServices.builder() - .name("mlflow_svc") - .serviceType("Mlflow") - .connection(mlflowConnection() - .trackingUri("http://localhost:8088") - .registryUri("http://localhost:8088")) - .create(); +import org.openmetadata.schema.api.services.CreateMlModelService; +import org.openmetadata.schema.api.services.CreateMlModelService.MlModelServiceType; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.schema.services.connections.mlmodel.MlflowConnection; +import org.openmetadata.schema.type.MlModelConnection; +import org.openmetadata.sdk.fluent.MlModelServices; + +CreateMlModelService request = new CreateMlModelService() + .withName("mlflow_svc") + .withServiceType(MlModelServiceType.Mlflow) + .withConnection(new MlModelConnection().withConfig( + new MlflowConnection() + .withTrackingUri("http://localhost:8088") + .withRegistryUri("http://localhost:8088"))); + +MlModelService service = MlModelServices.create(request); ``` ```bash POST /v1/services/mlmodelServices @@ -196,7 +212,7 @@ Returns the created ML model service object with all specified properties and sy - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker, CustomMlModel). + Type of ML model service, for example Mlflow, Sklearn, SageMaker, CustomMlModel. @@ -218,7 +234,7 @@ Returns the created ML model service object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -227,7 +243,7 @@ Returns the created ML model service object with all specified properties and sy - + Fully qualified name of the assigned domain. @@ -240,11 +256,11 @@ Returns the created ML model service object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/mlmodel-services/delete.mdx b/v1.13.x/api-reference/data-assets/mlmodel-services/delete.mdx index c2b42a870..43fcf5754 100644 --- a/v1.13.x/api-reference/data-assets/mlmodel-services/delete.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodel-services/delete.mdx @@ -28,7 +28,7 @@ Delete an ML model service by ID or fully qualified name. Supports soft delete ( Use `DELETE /v1/services/mlmodelServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the ML model service (e.g., `mlflow_svc`). + Fully qualified name of the ML model service, for example `mlflow_svc`. @@ -49,39 +49,56 @@ Use `PUT /v1/services/mlmodelServices/restore` to restore a soft-deleted ML mode ```python DELETE /v1/services/mlmodelServices/{id} -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Soft delete by ID -MlModelServices.delete("ca22d46e-81b9-4e48-85b5-0adc44980da9") +metadata.delete(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") # Hard delete -MlModelServices.delete( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", +metadata.delete( + entity=MlModelService, + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", hard_delete=True ) # Delete by name -MlModelServices.delete_by_name("mlflow_svc") +service = metadata.get_by_name(entity=MlModelService, fqn="mlflow_svc") +metadata.delete(entity=MlModelService, entity_id=service.id) # Delete by name with options -MlModelServices.delete_by_name( - "mlflow_svc", +service = metadata.get_by_name(entity=MlModelService, fqn="mlflow_svc") +metadata.delete( + entity=MlModelService, + entity_id=service.id, hard_delete=True, recursive=True ) # Restore a soft-deleted ML model service -MlModelServices.restore("ca22d46e-81b9-4e48-85b5-0adc44980da9") +metadata.restore(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") ``` ```java DELETE /v1/services/mlmodelServices/{id} -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.fluent.MlModelServices; + +// client is an initialized OpenMetadataClient. // Soft delete MlModelServices.delete("ca22d46e-81b9-4e48-85b5-0adc44980da9").execute(); @@ -91,11 +108,12 @@ MlModelServices.delete("ca22d46e-81b9-4e48-85b5-0adc44980da9") .hardDelete() .execute(); -// Delete by name -MlModelServices.deleteByName("mlflow_svc").execute(); +// Delete by name (look up the ID first) +MlModelService service = MlModelServices.retrieveByName("mlflow_svc"); +MlModelServices.delete(service.getId()).execute(); -// Restore -MlModelServices.restore("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +// Restore. The fluent class has no restore method, so use the client service. +client.mlModelServices().restore("ca22d46e-81b9-4e48-85b5-0adc44980da9"); ``` ```bash DELETE /v1/services/mlmodelServices/{id} diff --git a/v1.13.x/api-reference/data-assets/mlmodel-services/list.mdx b/v1.13.x/api-reference/data-assets/mlmodel-services/list.mdx index cc2b9b248..35f6a9674 100644 --- a/v1.13.x/api-reference/data-assets/mlmodel-services/list.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodel-services/list.mdx @@ -33,56 +33,64 @@ List all ML model services with optional filtering and pagination. ```python GET /v1/services/mlmodelServices -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List first page -services = MlModelServices.list(limit=50) -for svc in services.data: - print(f"{svc.fullyQualifiedName} ({svc.serviceType})") +services = metadata.list_entities(entity=MlModelService, limit=50) +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root} ({svc.serviceType.value})") # List all with auto-pagination -for svc in MlModelServices.list_all(): - print(f"{svc.fullyQualifiedName}") +for svc in metadata.list_all_entities(entity=MlModelService): + print(f"{svc.fullyQualifiedName.root}") # List with fields -services = MlModelServices.list( +services = metadata.list_entities( + entity=MlModelService, fields=["owners", "tags", "domains"], limit=50 ) -for svc in services.data: - print(f"{svc.fullyQualifiedName}") +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root}") if svc.owners: - print(f" Owners: {[o.name for o in svc.owners]}") + print(f" Owners: {[o.name for o in svc.owners.root]}") ``` ```java GET /v1/services/mlmodelServices -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = MlModelServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.mlModelServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (MlModelService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } -// List with fields -var result = MlModelServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); -} +// With fields +ListResponse withFields = client.mlModelServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/mlmodelServices @@ -160,7 +168,7 @@ Returns a paginated list of ML model service objects. By default, only basic fie - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker, CustomMlModel). + Type of ML model service, for example Mlflow, Sklearn, SageMaker, CustomMlModel. diff --git a/v1.13.x/api-reference/data-assets/mlmodel-services/retrieve.mdx b/v1.13.x/api-reference/data-assets/mlmodel-services/retrieve.mdx index cf91cf7ee..1bcee370b 100644 --- a/v1.13.x/api-reference/data-assets/mlmodel-services/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodel-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single ML model service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single ML model service by its unique ID or fully qualified name. Use `GET /v1/services/mlmodelServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the ML model service (e.g., `mlflow_svc`). + Fully qualified name of the ML model service, for example `mlflow_svc`. @@ -41,51 +41,64 @@ Use `GET /v1/services/mlmodelServices/name/{fqn}` to retrieve by fully qualified ```python GET /v1/services/mlmodelServices/{id} -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Get by ID -svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9") -print(f"{svc.fullyQualifiedName}: {svc.serviceType}") +svc = metadata.get_by_id(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") +print(f"{svc.fullyQualifiedName.root}: {svc.serviceType.value}") # Get by ID with fields -svc = MlModelServices.retrieve( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", +svc = metadata.get_by_id( + entity=MlModelService, + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", fields=["owners", "tags"] ) # Get by fully qualified name -svc = MlModelServices.retrieve_by_name("mlflow_svc") +svc = metadata.get_by_name(entity=MlModelService, fqn="mlflow_svc") # Get by name with fields -svc = MlModelServices.retrieve_by_name( - "mlflow_svc", +svc = metadata.get_by_name( + entity=MlModelService, + fqn="mlflow_svc", fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/services/mlmodelServices/{id} -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.fluent.MlModelServices; // Get by ID -var svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +MlModelService service = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); // Get by ID with fields -var svc = MlModelServices.retrieve( +MlModelService serviceWithFields = MlModelServices.retrieve( "ca22d46e-81b9-4e48-85b5-0adc44980da9", "owners,tags" ); // Get by fully qualified name -var svc = MlModelServices.retrieveByName("mlflow_svc"); +MlModelService serviceByName = MlModelServices.retrieveByName("mlflow_svc"); // Get by name with fields -var svc = MlModelServices.retrieveByName("mlflow_svc", "owners,tags,domains"); +MlModelService serviceByNameWithFields = MlModelServices.retrieveByName("mlflow_svc", "owners,tags,domains"); ``` ```bash GET /v1/services/mlmodelServices/{id} @@ -163,7 +176,7 @@ Returns an ML model service object with all requested fields populated. - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker, CustomMlModel). + Type of ML model service, for example Mlflow, Sklearn, SageMaker, CustomMlModel. diff --git a/v1.13.x/api-reference/data-assets/mlmodel-services/update.mdx b/v1.13.x/api-reference/data-assets/mlmodel-services/update.mdx index 9fa92a22e..f19c4f3d8 100644 --- a/v1.13.x/api-reference/data-assets/mlmodel-services/update.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodel-services/update.mdx @@ -20,7 +20,7 @@ Update an ML model service's properties using JSON Merge Patch. You can update b Use `PATCH /v1/services/mlmodelServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the ML model service (e.g., `mlflow_svc`). + Fully qualified name of the ML model service, for example `mlflow_svc`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,52 +68,58 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. ```python PATCH /v1/services/mlmodelServices/{id} -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Retrieve, modify, and update -svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9") -svc.description = "Updated: Production MLflow tracking server with model registry" -svc.connection = { - "config": { - "type": "Mlflow", - "trackingUri": "http://mlflow-prod:8088", - "registryUri": "http://mlflow-prod:8088", - "supportsMetadataExtraction": True - } -} -updated = MlModelServices.update(svc) - -print(f"Updated to version {updated.version}") +svc = metadata.get_by_id(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") +modified = svc.model_copy(deep=True) +modified.description = "Updated: Production MLflow tracking server with model registry" +modified.connection.config.trackingUri = "http://mlflow-prod:8088" +modified.connection.config.registryUri = "http://mlflow-prod:8088" +updated = metadata.patch(entity=MlModelService, source=svc, destination=modified) + +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/services/mlmodelServices/{id} -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.fluent.MlModelServices; // Retrieve, modify, and update -var svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); -svc.setDescription("Updated: Production MLflow tracking server with model registry"); -var updated = MlModelServices.update(svc); +MlModelService service = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +service.setDescription("Updated: Production MLflow tracking server with model registry"); +MlModelService updated = MlModelServices.update(service); ``` ```bash PATCH /v1/services/mlmodelServices/{id} diff --git a/v1.13.x/api-reference/data-assets/mlmodel-services/versions.mdx b/v1.13.x/api-reference/data-assets/mlmodel-services/versions.mdx index 7a37884e7..828c2be41 100644 --- a/v1.13.x/api-reference/data-assets/mlmodel-services/versions.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodel-services/versions.mdx @@ -24,47 +24,62 @@ Use `GET /v1/services/mlmodelServices/{id}/versions/{version}` to retrieve a spe - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/services/mlmodelServices/{id}/versions -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List all versions -versions = MlModelServices.get_versions("ca22d46e-81b9-4e48-85b5-0adc44980da9") -for v in versions: - print(f"Version {v.version}: {v.description}") +history = metadata.list_versions( + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", + entity=MlModelService +) +for v in history.versions: + svc_version = MlModelService.model_validate_json(v) + print(f"Version {svc_version.version.root}: {getattr(svc_version.description, 'root', svc_version.description)}") # Get a specific version -svc_v1 = MlModelServices.get_specific_version( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", - "0.1" +svc_v1 = metadata.get_entity_version( + entity=MlModelService, + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", + version="0.1" ) -print(f"Original description: {svc_v1.description}") +print(f"Original description: {getattr(svc_v1.description, 'root', svc_v1.description)}") ``` ```java GET /v1/services/mlmodelServices/{id}/versions -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = MlModelServices.getVersions("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +EntityHistory history = client.mlModelServices().getVersionList("ca22d46e-81b9-4e48-85b5-0adc44980da9"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = MlModelServices.getSpecificVersion( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", - 0.1 -); +MlModelService v1 = client.mlModelServices().getVersion("ca22d46e-81b9-4e48-85b5-0adc44980da9", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/mlmodels/create.mdx b/v1.13.x/api-reference/data-assets/mlmodels/create.mdx index a637fadc9..d7a44ac80 100644 --- a/v1.13.x/api-reference/data-assets/mlmodels/create.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodels/create.mdx @@ -16,11 +16,11 @@ Create a new ML model within an ML model service. - Fully qualified name of the parent MlModelService (e.g., `mlflow_svc`). + Fully qualified name of the parent MlModelService, for example `mlflow_svc`. - Algorithm used by the ML model (e.g., `KMeans`, `RandomForest`, `XGBoost`, `Neural Network`). + Algorithm used by the ML model, for example `KMeans`, `RandomForest`, `XGBoost`, `Neural Network`. @@ -40,7 +40,7 @@ Create a new ML model within an ML model service. - Data type of the feature (e.g., `numerical`, `categorical`). + Data type of the feature, for example `numerical`, `categorical`. @@ -56,7 +56,7 @@ Create a new ML model within an ML model service. - Reference to the source entity (e.g., a table or column). + Reference to the source entity, for example a table or column. @@ -108,7 +108,7 @@ Create a new ML model within an ML model service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -117,8 +117,8 @@ Create a new ML model within an ML model service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -130,11 +130,11 @@ Create a new ML model within an ML model service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -178,20 +178,28 @@ request = CreateMlModelRequest( ) model = MLModels.create(request) -print(f"Created: {model.fullyQualifiedName}") +print(f"Created: {model.fullyQualifiedName.root}") ``` ```java POST /v1/mlmodels -import static org.openmetadata.sdk.fluent.MlModels.*; - -// Create using builder pattern -var model = MlModels.builder() - .name("customer_segmentation") - .displayName("Customer Segmentation Model") - .service("mlflow_svc") - .algorithm("KMeans") - .description("Segments customers into groups based on purchasing behavior") - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateMlModel; +import org.openmetadata.schema.entity.data.MlModel; +import org.openmetadata.schema.type.MlFeature; +import org.openmetadata.schema.type.MlFeatureDataType; +import org.openmetadata.sdk.fluent.MlModels; + +CreateMlModel request = new CreateMlModel() + .withName("customer_segmentation") + .withDisplayName("Customer Segmentation Model") + .withService("mlflow_svc") + .withAlgorithm("KMeans") + .withDescription("Segments customers into groups based on purchasing behavior") + .withMlFeatures(List.of( + new MlFeature().withName("total_spend").withDataType(MlFeatureDataType.Numerical), + new MlFeature().withName("purchase_frequency").withDataType(MlFeatureDataType.Numerical))); + +MlModel model = MlModels.create(request); ``` ```bash POST /v1/mlmodels @@ -363,7 +371,7 @@ Returns the created ML model object with all specified properties and system-gen - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker). + Type of ML model service, for example Mlflow, Sklearn, SageMaker. @@ -375,7 +383,7 @@ Returns the created ML model object with all specified properties and system-gen - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -397,11 +405,11 @@ Returns the created ML model object with all specified properties and system-gen - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/mlmodels/delete.mdx b/v1.13.x/api-reference/data-assets/mlmodels/delete.mdx index 9acd600a0..93a26ebd3 100644 --- a/v1.13.x/api-reference/data-assets/mlmodels/delete.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodels/delete.mdx @@ -28,7 +28,7 @@ Delete an ML model by ID or fully qualified name. Supports soft delete (default) Use `DELETE /v1/mlmodels/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the ML model (e.g., `mlflow_svc.customer_segmentation`). + Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`. @@ -67,11 +67,13 @@ MLModels.delete( ) # Delete by name -MLModels.delete_by_name("mlflow_svc.customer_segmentation") +model = MLModels.retrieve_by_name("mlflow_svc.customer_segmentation") +MLModels.delete(model.id) # Delete by name with options -MLModels.delete_by_name( - "mlflow_svc.customer_segmentation", +model = MLModels.retrieve_by_name("mlflow_svc.customer_segmentation") +MLModels.delete( + model.id, hard_delete=True ) @@ -80,21 +82,23 @@ MLModels.restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") ``` ```java DELETE /v1/mlmodels/{id} -import static org.openmetadata.sdk.fluent.MlModels.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.MlModel; + +// client is an initialized OpenMetadataClient. // Soft delete -MlModels.delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2").execute(); +client.mlModels().delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); // Hard delete -MlModels.delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") - .hardDelete() - .execute(); +client.mlModels().delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", Map.of("hardDelete", "true")); -// Delete by name -MlModels.deleteByName("mlflow_svc.customer_segmentation").execute(); +// Delete by name (look up the ID first) +MlModel model = client.mlModels().getByName("mlflow_svc.customer_segmentation"); +client.mlModels().delete(model.getId()); // Restore -MlModels.restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +client.mlModels().restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); ``` ```bash DELETE /v1/mlmodels/{id} diff --git a/v1.13.x/api-reference/data-assets/mlmodels/followers-votes.mdx b/v1.13.x/api-reference/data-assets/mlmodels/followers-votes.mdx index a1d991972..f81404a73 100644 --- a/v1.13.x/api-reference/data-assets/mlmodels/followers-votes.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodels/followers-votes.mdx @@ -51,47 +51,56 @@ Manage followers and votes for ML model entities. ```python PUT /v1/mlmodels/{id}/followers -from metadata.sdk import configure +from metadata.sdk import client, configure from metadata.sdk.entities import MLModels configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client model_id = "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2" user_id = "user-uuid-here" # Add a follower model = MLModels.add_followers(model_id, [user_id]) -print(f"Followers: {len(model.followers)}") +print(f"Followers: {len(model.followers.root)}") # Remove a follower model = MLModels.remove_followers(model_id, [user_id]) # Add a vote -model = MLModels.add_vote(model_id, vote_type="votedUp") +rest.put(f"/mlmodels/{model_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -model = MLModels.remove_vote(model_id) +rest.put(f"/mlmodels/{model_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/mlmodels/{id}/followers -import static org.openmetadata.sdk.fluent.MlModels.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String modelId = "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -MlModels.addFollower(modelId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/mlmodels/" + modelId + "/followers", userId); // Remove a follower -MlModels.removeFollower(modelId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/mlmodels/" + modelId + "/followers/" + userId, null); // Add a vote -MlModels.vote(modelId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/mlmodels/" + modelId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -MlModels.vote(modelId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/mlmodels/" + modelId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/mlmodels/{id}/followers diff --git a/v1.13.x/api-reference/data-assets/mlmodels/list.mdx b/v1.13.x/api-reference/data-assets/mlmodels/list.mdx index 8c39be9a6..989135a51 100644 --- a/v1.13.x/api-reference/data-assets/mlmodels/list.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodels/list.mdx @@ -47,49 +47,52 @@ configure( # List first page models = MLModels.list(limit=50) -for m in models.data: - print(f"{m.fullyQualifiedName} ({m.algorithm})") +for m in models.entities: + print(f"{m.fullyQualifiedName.root} ({m.algorithm})") # List all with auto-pagination for m in MLModels.list_all(): - print(f"{m.fullyQualifiedName}") + print(f"{m.fullyQualifiedName.root}") # Filter by service models = MLModels.list( - service="mlflow_svc", + filters={"service": "mlflow_svc"}, fields=["owners", "tags", "domains"], limit=50 ) -for m in models.data: - print(f"{m.fullyQualifiedName}") +for m in models.entities: + print(f"{m.fullyQualifiedName.root}") if m.owners: - print(f" Owners: {[o.name for o in m.owners]}") + print(f" Owners: {[o.name for o in m.owners.root]}") if m.tags: - print(f" Tags: {[t.tagFQN for t in m.tags]}") + print(f" Tags: {[tag.tagFQN.root for tag in m.tags]}") ``` ```java GET /v1/mlmodels -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = MlModels.list() - .limit(50) - .execute(); +ListResponse firstPage = client.mlModels().list(new ListParams().setLimit(50)); -for (var m : result.getData()) { - System.out.println(m.getFullyQualifiedName()); +for (MlModel item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = MlModels.list() - .service("mlflow_svc") - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var m : result.getData()) { - System.out.println(m.getFullyQualifiedName()); +ListResponse filtered = client.mlModels().list( + new ListParams() + .setService("mlflow_svc") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (MlModel item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -186,7 +189,7 @@ Returns a paginated list of ML model objects. By default, only basic fields are - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker). + Type of ML model service, for example Mlflow, Sklearn, SageMaker. diff --git a/v1.13.x/api-reference/data-assets/mlmodels/retrieve.mdx b/v1.13.x/api-reference/data-assets/mlmodels/retrieve.mdx index 6bf39484c..19f1c2222 100644 --- a/v1.13.x/api-reference/data-assets/mlmodels/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodels/retrieve.mdx @@ -16,7 +16,7 @@ Get a single ML model by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single ML model by its unique ID or fully qualified name. Use `GET /v1/mlmodels/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the ML model (e.g., `mlflow_svc.customer_segmentation`). + Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`. @@ -51,7 +51,7 @@ configure( # Get by ID model = MLModels.retrieve("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") -print(f"{model.fullyQualifiedName}: {model.algorithm}") +print(f"{model.fullyQualifiedName.root}: {model.algorithm}") # Get by ID with fields model = MLModels.retrieve( @@ -70,22 +70,24 @@ model = MLModels.retrieve_by_name( ``` ```java GET /v1/mlmodels/{id} -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; + +// client is an initialized OpenMetadataClient. // Get by ID -var model = MlModels.retrieve("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +MlModel model = client.mlModels().get("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); // Get by ID with fields -var model = MlModels.retrieve( +MlModel modelWithFields = client.mlModels().get( "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", "owners,tags,followers,votes" ); // Get by fully qualified name -var model = MlModels.retrieveByName("mlflow_svc.customer_segmentation"); +MlModel modelByName = client.mlModels().getByName("mlflow_svc.customer_segmentation"); // Get by name with fields -var model = MlModels.retrieveByName( +MlModel modelByNameWithFields = client.mlModels().getByName( "mlflow_svc.customer_segmentation", "owners,tags,domains" ); @@ -210,7 +212,7 @@ Returns an ML model object with all requested fields populated. - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker). + Type of ML model service, for example Mlflow, Sklearn, SageMaker. diff --git a/v1.13.x/api-reference/data-assets/mlmodels/update.mdx b/v1.13.x/api-reference/data-assets/mlmodels/update.mdx index 8e4a00e1a..0371a8256 100644 --- a/v1.13.x/api-reference/data-assets/mlmodels/update.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodels/update.mdx @@ -20,7 +20,7 @@ Update an ML model's properties using JSON Merge Patch. You can update by ID or Use `PATCH /v1/mlmodels/name/{fqn}` to update by fully qualified name. - Fully qualified name of the ML model (e.g., `mlflow_svc.customer_segmentation`). + Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Data type of the feature (e.g., `numerical`, `categorical`). + Data type of the feature, for example `numerical`, `categorical`. @@ -80,7 +80,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -94,17 +94,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -130,16 +130,18 @@ model.mlHyperParameters = [ ] updated = MLModels.update(model) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/mlmodels/{id} -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var model = MlModels.retrieve("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +MlModel model = client.mlModels().get("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); model.setDescription("Updated: Customer segmentation using KMeans with 5 clusters"); -var updated = MlModels.update(model); +MlModel updated = client.mlModels().update(model.getId(), model); ``` ```bash PATCH /v1/mlmodels/{id} diff --git a/v1.13.x/api-reference/data-assets/mlmodels/versions.mdx b/v1.13.x/api-reference/data-assets/mlmodels/versions.mdx index 51758b323..c97d78f78 100644 --- a/v1.13.x/api-reference/data-assets/mlmodels/versions.mdx +++ b/v1.13.x/api-reference/data-assets/mlmodels/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/mlmodels/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/mlmodels/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import MLModels @@ -40,7 +42,8 @@ configure( # List all versions versions = MLModels.get_versions("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version model_v1 = MLModels.get_specific_version( @@ -51,21 +54,21 @@ print(f"Original algorithm: {model_v1.algorithm}") ``` ```java GET /v1/mlmodels/{id}/versions -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = MlModels.getVersions("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +EntityHistory history = client.mlModels().getVersionList("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = MlModels.getSpecificVersion( - "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", - 0.1 -); -System.out.println("Algorithm: " + v1.getAlgorithm()); +MlModel v1 = client.mlModels().getVersion("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", 0.1); +System.out.println("Description: " + v1.getDescription()); ``` ```bash GET /v1/mlmodels/{id}/versions diff --git a/v1.13.x/api-reference/data-assets/pipeline-services/create.mdx b/v1.13.x/api-reference/data-assets/pipeline-services/create.mdx index eca9f3d69..34be0380b 100644 --- a/v1.13.x/api-reference/data-assets/pipeline-services/create.mdx +++ b/v1.13.x/api-reference/data-assets/pipeline-services/create.mdx @@ -16,7 +16,7 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Type of pipeline service (e.g., `Airflow`, `GluePipeline`, `Airbyte`, `Dagster`, `Fivetran`, `DBTCloud`, `Nifi`, `DomoPipeline`, `CustomPipeline`, `Flink`, `KafkaConnect`, `SplineProducer`, `OpenLineage`). + Type of pipeline service, for example `Airflow`, `GluePipeline`, `Airbyte`, `Dagster`, `Fivetran`, `DBTCloud`, `Nifi`, `DomoPipeline`, `CustomPipeline`, `Flink`, `KafkaConnect`, `SplineProducer`, `OpenLineage`. @@ -24,7 +24,7 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Service-specific connection configuration (e.g., host, port, authentication for Airflow). + Service-specific connection configuration, for example host, port, authentication for Airflow. @@ -46,7 +46,7 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -113,14 +113,24 @@ print(f"Created: {service['fullyQualifiedName']}") ``` ```java POST /v1/services/pipelineServices -import static org.openmetadata.sdk.fluent.PipelineServices.*; - -PipelineService service = PipelineServices.builder() - .name("sample_airflow") - .serviceType("Airflow") - .connection(airflowConnection() - .hostPort("http://localhost:8080")) - .create(); +import java.net.URI; +import org.openmetadata.schema.api.services.CreatePipelineService; +import org.openmetadata.schema.api.services.CreatePipelineService.PipelineServiceType; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.schema.services.connections.pipeline.AirflowConnection; +import org.openmetadata.schema.services.connections.pipeline.BackendConnection; +import org.openmetadata.schema.type.PipelineConnection; +import org.openmetadata.sdk.fluent.PipelineServices; + +CreatePipelineService request = new CreatePipelineService() + .withName("sample_airflow") + .withServiceType(PipelineServiceType.Airflow) + .withConnection(new PipelineConnection().withConfig( + new AirflowConnection() + .withHostPort(URI.create("http://localhost:8080")) + .withConnection(new BackendConnection()))); + +PipelineService service = PipelineServices.create(request); ``` ```bash POST /v1/services/pipelineServices @@ -202,7 +212,7 @@ Returns the created pipeline service object with all specified properties and sy - Type of pipeline service (e.g., Airflow, Dagster, Fivetran). + Type of pipeline service, for example Airflow, Dagster, Fivetran. @@ -224,7 +234,7 @@ Returns the created pipeline service object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -233,7 +243,7 @@ Returns the created pipeline service object with all specified properties and sy - + Fully qualified name of the assigned domain. @@ -246,11 +256,11 @@ Returns the created pipeline service object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/pipeline-services/delete.mdx b/v1.13.x/api-reference/data-assets/pipeline-services/delete.mdx index 1aca19934..1ab3ef4b0 100644 --- a/v1.13.x/api-reference/data-assets/pipeline-services/delete.mdx +++ b/v1.13.x/api-reference/data-assets/pipeline-services/delete.mdx @@ -28,7 +28,7 @@ Delete a pipeline service by ID or fully qualified name. Supports soft delete (d Use `DELETE /v1/services/pipelineServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. @@ -81,7 +81,10 @@ requests.put( ``` ```java DELETE /v1/services/pipelineServices/{id} -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.fluent.PipelineServices; + +// client is an initialized OpenMetadataClient. // Soft delete PipelineServices.delete("daa58a49-df05-48a3-a417-45dfd12eacf5").execute(); @@ -92,11 +95,12 @@ PipelineServices.delete("daa58a49-df05-48a3-a417-45dfd12eacf5") .recursive() .execute(); -// Delete by name -PipelineServices.deleteByName("sample_airflow").execute(); +// Delete by name (look up the ID first) +PipelineService service = PipelineServices.retrieveByName("sample_airflow"); +PipelineServices.delete(service.getId()).execute(); -// Restore -PipelineServices.restore("daa58a49-df05-48a3-a417-45dfd12eacf5"); +// Restore. The fluent class has no restore method, so use the client service. +client.pipelineServices().restore("daa58a49-df05-48a3-a417-45dfd12eacf5"); ``` ```bash DELETE /v1/services/pipelineServices/{id} diff --git a/v1.13.x/api-reference/data-assets/pipeline-services/import-export.mdx b/v1.13.x/api-reference/data-assets/pipeline-services/import-export.mdx index a1e545dda..86c70b4c1 100644 --- a/v1.13.x/api-reference/data-assets/pipeline-services/import-export.mdx +++ b/v1.13.x/api-reference/data-assets/pipeline-services/import-export.mdx @@ -14,7 +14,7 @@ Export pipeline service metadata (pipelines, owners, tags) to CSV and import cha `GET /v1/services/pipelineServices/name/{fqn}/export` - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. ## Export Async @@ -79,38 +79,6 @@ response = requests.put( ) ``` -```java GET /v1/services/pipelineServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.PipelineServices; - -// Synchronous export -String csvData = PipelineServices.exportCsv("sample_airflow") - .execute(); - -// Async export -String jobId = PipelineServices.exportCsv("sample_airflow") - .async() - .execute(); - -// Synchronous import (dry run) -String result = PipelineServices.importCsv("sample_airflow") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = PipelineServices.importCsv("sample_airflow") - .withData(csvData) - .dryRun(false) - .execute(); - -// Async import -String jobId = PipelineServices.importCsv("sample_airflow") - .withData(csvData) - .dryRun(false) - .async() - .execute(); -``` - ```bash GET /v1/services/pipelineServices/name/{fqn}/export # Export to CSV curl "{base_url}/api/v1/services/pipelineServices/name/sample_airflow/export" \ diff --git a/v1.13.x/api-reference/data-assets/pipeline-services/list.mdx b/v1.13.x/api-reference/data-assets/pipeline-services/list.mdx index 3d20896a1..32ff85447 100644 --- a/v1.13.x/api-reference/data-assets/pipeline-services/list.mdx +++ b/v1.13.x/api-reference/data-assets/pipeline-services/list.mdx @@ -55,22 +55,23 @@ response = requests.get( ``` ```java GET /v1/services/pipelineServices -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = PipelineServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.pipelineServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (PipelineService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } // With fields -var result = PipelineServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); +ListResponse withFields = client.pipelineServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/pipelineServices @@ -140,7 +141,7 @@ Returns a paginated list of pipeline service objects. By default, only basic fie - Type of pipeline service (e.g., Airflow, Dagster, Fivetran). + Type of pipeline service, for example Airflow, Dagster, Fivetran. diff --git a/v1.13.x/api-reference/data-assets/pipeline-services/retrieve.mdx b/v1.13.x/api-reference/data-assets/pipeline-services/retrieve.mdx index 69e8c852f..00405a859 100644 --- a/v1.13.x/api-reference/data-assets/pipeline-services/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/pipeline-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single pipeline service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single pipeline service by its unique ID or fully qualified name. Use `GET /v1/services/pipelineServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. @@ -74,22 +74,23 @@ response = requests.get( ``` ```java GET /v1/services/pipelineServices/{id} -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.fluent.PipelineServices; // Get by ID -var svc = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); +PipelineService service = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); // Get by ID with fields -var svc = PipelineServices.retrieve( +PipelineService serviceWithFields = PipelineServices.retrieve( "daa58a49-df05-48a3-a417-45dfd12eacf5", "owners,tags,domains" ); // Get by fully qualified name -var svc = PipelineServices.retrieveByName("sample_airflow"); +PipelineService serviceByName = PipelineServices.retrieveByName("sample_airflow"); // Get by name with fields -var svc = PipelineServices.retrieveByName("sample_airflow", "owners,tags,domains"); +PipelineService serviceByNameWithFields = PipelineServices.retrieveByName("sample_airflow", "owners,tags,domains"); ``` ```bash GET /v1/services/pipelineServices/{id} @@ -159,7 +160,7 @@ Returns a pipeline service object with all requested fields populated. - Type of pipeline service (e.g., Airflow, Dagster, Fivetran). + Type of pipeline service, for example Airflow, Dagster, Fivetran. diff --git a/v1.13.x/api-reference/data-assets/pipeline-services/update.mdx b/v1.13.x/api-reference/data-assets/pipeline-services/update.mdx index e7440acf3..8a667bb88 100644 --- a/v1.13.x/api-reference/data-assets/pipeline-services/update.mdx +++ b/v1.13.x/api-reference/data-assets/pipeline-services/update.mdx @@ -20,7 +20,7 @@ Update a pipeline service's properties using JSON Merge Patch. You can update by Use `PATCH /v1/services/pipelineServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -104,12 +104,13 @@ print(f"Updated to version {updated['version']}") ``` ```java PATCH /v1/services/pipelineServices/{id} -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.fluent.PipelineServices; // Retrieve, modify, and update -var svc = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); -svc.setDescription("Updated Airflow production service"); -var updated = PipelineServices.update(svc); +PipelineService service = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); +service.setDescription("Updated Airflow production service"); +PipelineService updated = PipelineServices.update(service); ``` ```bash PATCH /v1/services/pipelineServices/{id} diff --git a/v1.13.x/api-reference/data-assets/pipeline-services/versions.mdx b/v1.13.x/api-reference/data-assets/pipeline-services/versions.mdx index 784d989f5..61dacd402 100644 --- a/v1.13.x/api-reference/data-assets/pipeline-services/versions.mdx +++ b/v1.13.x/api-reference/data-assets/pipeline-services/versions.mdx @@ -24,7 +24,7 @@ Use `GET /v1/services/pipelineServices/{id}/versions/{version}` to retrieve a sp - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. @@ -51,20 +51,20 @@ response = requests.get( ``` ```java GET /v1/services/pipelineServices/{id}/versions -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = PipelineServices.getVersions("daa58a49-df05-48a3-a417-45dfd12eacf5"); +EntityHistory history = client.pipelineServices().getVersionList("daa58a49-df05-48a3-a417-45dfd12eacf5"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = PipelineServices.getSpecificVersion( - "daa58a49-df05-48a3-a417-45dfd12eacf5", - 0.1 -); +PipelineService v1 = client.pipelineServices().getVersion("daa58a49-df05-48a3-a417-45dfd12eacf5", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/pipelines/create.mdx b/v1.13.x/api-reference/data-assets/pipelines/create.mdx index d321f385a..72bf64500 100644 --- a/v1.13.x/api-reference/data-assets/pipelines/create.mdx +++ b/v1.13.x/api-reference/data-assets/pipelines/create.mdx @@ -16,7 +16,7 @@ Create a new pipeline within a pipeline service. - Fully qualified name of the parent PipelineService (e.g., `sample_airflow`). + Fully qualified name of the parent PipelineService, for example `sample_airflow`. @@ -28,7 +28,7 @@ Create a new pipeline within a pipeline service. - URL to the pipeline definition in the source system (e.g., Airflow DAG URL). + URL to the pipeline definition in the source system, for example Airflow DAG URL. @@ -48,7 +48,7 @@ Create a new pipeline within a pipeline service. - Type of the task (e.g., `BatchTask`, `StreamTask`). + Type of the task, for example `BatchTask`, `StreamTask`. @@ -70,7 +70,7 @@ Create a new pipeline within a pipeline service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -79,8 +79,8 @@ Create a new pipeline within a pipeline service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -92,11 +92,11 @@ Create a new pipeline within a pipeline service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -144,19 +144,21 @@ request = CreatePipelineRequest( ) pipeline = Pipelines.create(request) -print(f"Created: {pipeline.fullyQualifiedName}") +print(f"Created: {pipeline.fullyQualifiedName.root}") ``` ```java POST /v1/pipelines -import static org.openmetadata.sdk.fluent.Pipelines.*; - -// Create using builder pattern -var pipeline = Pipelines.builder() - .name("dbt_analytics_customers") - .displayName("DBT Customer Analytics") - .service("sample_airflow") - .description("Analytics pipeline for customer data processing") - .create(); +import org.openmetadata.schema.api.data.CreatePipeline; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.sdk.fluent.Pipelines; + +CreatePipeline request = new CreatePipeline() + .withName("dbt_analytics_customers") + .withDisplayName("DBT Customer Analytics") + .withService("sample_airflow") + .withDescription("Analytics pipeline for customer data processing"); + +Pipeline pipeline = Pipelines.create(request); ``` ```bash POST /v1/pipelines @@ -300,7 +302,7 @@ Returns the created pipeline object with all specified properties and system-gen - Type of pipeline service (e.g., Airflow, Dagster, DBTCloud). + Type of pipeline service, for example Airflow, Dagster, DBTCloud. @@ -334,7 +336,7 @@ Returns the created pipeline object with all specified properties and system-gen - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -356,11 +358,11 @@ Returns the created pipeline object with all specified properties and system-gen - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/pipelines/delete.mdx b/v1.13.x/api-reference/data-assets/pipelines/delete.mdx index 3c4ef637c..a5c660bff 100644 --- a/v1.13.x/api-reference/data-assets/pipelines/delete.mdx +++ b/v1.13.x/api-reference/data-assets/pipelines/delete.mdx @@ -28,7 +28,7 @@ Delete a pipeline by ID or fully qualified name. Supports soft delete (default), Use `DELETE /v1/pipelines/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the pipeline (e.g., `sample_airflow.dbt_analytics_customers`). + Fully qualified name of the pipeline, for example `sample_airflow.dbt_analytics_customers`. @@ -67,11 +67,13 @@ Pipelines.delete( ) # Delete by name -Pipelines.delete_by_name("sample_airflow.dbt_analytics_customers") +pipeline = Pipelines.retrieve_by_name("sample_airflow.dbt_analytics_customers") +Pipelines.delete(pipeline.id) # Delete by name with options -Pipelines.delete_by_name( - "sample_airflow.dbt_analytics_customers", +pipeline = Pipelines.retrieve_by_name("sample_airflow.dbt_analytics_customers") +Pipelines.delete( + pipeline.id, hard_delete=True ) @@ -80,22 +82,23 @@ Pipelines.restore("538faa63-d204-46ff-aead-d158d0401cac") ``` ```java DELETE /v1/pipelines/{id} -import static org.openmetadata.sdk.fluent.Pipelines.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.Pipeline; + +// client is an initialized OpenMetadataClient. // Soft delete -Pipelines.delete("538faa63-d204-46ff-aead-d158d0401cac").execute(); +client.pipelines().delete("538faa63-d204-46ff-aead-d158d0401cac"); // Hard delete -Pipelines.delete("538faa63-d204-46ff-aead-d158d0401cac") - .hardDelete() - .execute(); +client.pipelines().delete("538faa63-d204-46ff-aead-d158d0401cac", Map.of("hardDelete", "true")); -// Delete by name -Pipelines.deleteByName("sample_airflow.dbt_analytics_customers") - .execute(); +// Delete by name (look up the ID first) +Pipeline pipeline = client.pipelines().getByName("sample_airflow.dbt_analytics_customers"); +client.pipelines().delete(pipeline.getId()); // Restore -Pipelines.restore("538faa63-d204-46ff-aead-d158d0401cac"); +client.pipelines().restore("538faa63-d204-46ff-aead-d158d0401cac"); ``` ```bash DELETE /v1/pipelines/{id} diff --git a/v1.13.x/api-reference/data-assets/pipelines/followers-votes.mdx b/v1.13.x/api-reference/data-assets/pipelines/followers-votes.mdx index 91de606b7..111fe82f2 100644 --- a/v1.13.x/api-reference/data-assets/pipelines/followers-votes.mdx +++ b/v1.13.x/api-reference/data-assets/pipelines/followers-votes.mdx @@ -51,47 +51,56 @@ Manage followers and votes for pipeline entities. ```python PUT /v1/pipelines/{id}/followers -from metadata.sdk import configure +from metadata.sdk import client, configure from metadata.sdk.entities import Pipelines configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client pipeline_id = "538faa63-d204-46ff-aead-d158d0401cac" user_id = "user-uuid-here" # Add a follower pipeline = Pipelines.add_followers(pipeline_id, [user_id]) -print(f"Followers: {len(pipeline.followers)}") +print(f"Followers: {len(pipeline.followers.root)}") # Remove a follower pipeline = Pipelines.remove_followers(pipeline_id, [user_id]) # Add a vote -pipeline = Pipelines.add_vote(pipeline_id, vote_type="votedUp") +rest.put(f"/pipelines/{pipeline_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -pipeline = Pipelines.remove_vote(pipeline_id) +rest.put(f"/pipelines/{pipeline_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/pipelines/{id}/followers -import static org.openmetadata.sdk.fluent.Pipelines.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String pipelineId = "538faa63-d204-46ff-aead-d158d0401cac"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -Pipelines.addFollower(pipelineId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/pipelines/" + pipelineId + "/followers", userId); // Remove a follower -Pipelines.removeFollower(pipelineId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/pipelines/" + pipelineId + "/followers/" + userId, null); // Add a vote -Pipelines.vote(pipelineId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/pipelines/" + pipelineId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -Pipelines.vote(pipelineId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/pipelines/" + pipelineId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/pipelines/{id}/followers diff --git a/v1.13.x/api-reference/data-assets/pipelines/list.mdx b/v1.13.x/api-reference/data-assets/pipelines/list.mdx index 173a1f872..a299d584d 100644 --- a/v1.13.x/api-reference/data-assets/pipelines/list.mdx +++ b/v1.13.x/api-reference/data-assets/pipelines/list.mdx @@ -47,49 +47,52 @@ configure( # List first page pipelines = Pipelines.list(limit=50) -for p in pipelines.data: - print(f"{p.fullyQualifiedName}") +for p in pipelines.entities: + print(f"{p.fullyQualifiedName.root}") # List all with auto-pagination for p in Pipelines.list_all(): - print(f"{p.fullyQualifiedName}") + print(f"{p.fullyQualifiedName.root}") # Filter by service pipelines = Pipelines.list( - service="sample_airflow", + filters={"service": "sample_airflow"}, fields=["owners", "tags", "tasks"], limit=50 ) -for p in pipelines.data: - print(f"{p.fullyQualifiedName}") +for p in pipelines.entities: + print(f"{p.fullyQualifiedName.root}") if p.owners: - print(f" Owners: {[o.name for o in p.owners]}") + print(f" Owners: {[o.name for o in p.owners.root]}") if p.tasks: - print(f" Tasks: {[t.name for t in p.tasks]}") + print(f" Tasks: {[task.name for task in p.tasks]}") ``` ```java GET /v1/pipelines -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = Pipelines.list() - .limit(50) - .execute(); +ListResponse firstPage = client.pipelines().list(new ListParams().setLimit(50)); -for (var p : result.getData()) { - System.out.println(p.getFullyQualifiedName()); +for (Pipeline item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = Pipelines.list() - .service("sample_airflow") - .fields("owners", "tags", "tasks") - .limit(50) - .execute(); - -for (var p : result.getData()) { - System.out.println(p.getFullyQualifiedName()); +ListResponse filtered = client.pipelines().list( + new ListParams() + .setService("sample_airflow") + .setFields("owners,tags,tasks") + .setLimit(50) +); + +for (Pipeline item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -181,7 +184,7 @@ Returns a paginated list of pipeline objects. By default, only basic fields are - Type of pipeline service (e.g., Airflow, Dagster, DBTCloud). + Type of pipeline service, for example Airflow, Dagster, DBTCloud. diff --git a/v1.13.x/api-reference/data-assets/pipelines/retrieve.mdx b/v1.13.x/api-reference/data-assets/pipelines/retrieve.mdx index 07a8956c3..15a7c5753 100644 --- a/v1.13.x/api-reference/data-assets/pipelines/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/pipelines/retrieve.mdx @@ -16,7 +16,7 @@ Get a single pipeline by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,tasks,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,tasks,sourceHash`. @@ -28,7 +28,7 @@ Get a single pipeline by its unique ID or fully qualified name. Use `GET /v1/pipelines/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the pipeline (e.g., `sample_airflow.dbt_analytics_customers`). + Fully qualified name of the pipeline, for example `sample_airflow.dbt_analytics_customers`. @@ -51,7 +51,7 @@ configure( # Get by ID pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac") -print(f"{pipeline.fullyQualifiedName}: {pipeline.description}") +print(f"{pipeline.fullyQualifiedName.root}: {getattr(pipeline.description, 'root', pipeline.description)}") # Get by ID with fields pipeline = Pipelines.retrieve( @@ -65,31 +65,31 @@ pipeline = Pipelines.retrieve_by_name("sample_airflow.dbt_analytics_customers") # Get by name with fields pipeline = Pipelines.retrieve_by_name( "sample_airflow.dbt_analytics_customers", - fields=["owners", "tags", "tasks", "domain"] + fields=["owners", "tags", "tasks", "domains"] ) ``` ```java GET /v1/pipelines/{id} -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; + +// client is an initialized OpenMetadataClient. // Get by ID -var pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac"); +Pipeline pipeline = client.pipelines().get("538faa63-d204-46ff-aead-d158d0401cac"); // Get by ID with fields -var pipeline = Pipelines.retrieve( +Pipeline pipelineWithFields = client.pipelines().get( "538faa63-d204-46ff-aead-d158d0401cac", "owners,tags,tasks" ); // Get by fully qualified name -var pipeline = Pipelines.retrieveByName( - "sample_airflow.dbt_analytics_customers" -); +Pipeline pipelineByName = client.pipelines().getByName("sample_airflow.dbt_analytics_customers"); // Get by name with fields -var pipeline = Pipelines.retrieveByName( +Pipeline pipelineByNameWithFields = client.pipelines().getByName( "sample_airflow.dbt_analytics_customers", - "owners,tags,tasks,domain" + "owners,tags,tasks,domains" ); ``` @@ -201,7 +201,7 @@ Returns a pipeline object with all requested fields populated. - Type of pipeline service (e.g., Airflow, Dagster, DBTCloud). + Type of pipeline service, for example Airflow, Dagster, DBTCloud. diff --git a/v1.13.x/api-reference/data-assets/pipelines/update.mdx b/v1.13.x/api-reference/data-assets/pipelines/update.mdx index 7e63e4e60..d28464480 100644 --- a/v1.13.x/api-reference/data-assets/pipelines/update.mdx +++ b/v1.13.x/api-reference/data-assets/pipelines/update.mdx @@ -20,7 +20,7 @@ Update a pipeline's properties using JSON Merge Patch. You can update by ID or b Use `PATCH /v1/pipelines/name/{fqn}` to update by fully qualified name. - Fully qualified name of the pipeline (e.g., `sample_airflow.dbt_analytics_customers`). + Fully qualified name of the pipeline, for example `sample_airflow.dbt_analytics_customers`. ## Body Parameters @@ -70,7 +70,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -84,17 +84,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -116,16 +116,18 @@ pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac") pipeline.description = "Updated: Analytics pipeline with incremental customer processing" updated = Pipelines.update(pipeline) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/pipelines/{id} -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac"); +Pipeline pipeline = client.pipelines().get("538faa63-d204-46ff-aead-d158d0401cac"); pipeline.setDescription("Updated: Analytics pipeline with incremental customer processing"); -var updated = Pipelines.update(pipeline); +Pipeline updated = client.pipelines().update(pipeline.getId(), pipeline); ``` ```bash PATCH /v1/pipelines/{id} diff --git a/v1.13.x/api-reference/data-assets/pipelines/versions.mdx b/v1.13.x/api-reference/data-assets/pipelines/versions.mdx index 91884d0d7..23ccd44a5 100644 --- a/v1.13.x/api-reference/data-assets/pipelines/versions.mdx +++ b/v1.13.x/api-reference/data-assets/pipelines/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/pipelines/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/pipelines/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Pipelines @@ -40,31 +42,32 @@ configure( # List all versions versions = Pipelines.get_versions("538faa63-d204-46ff-aead-d158d0401cac") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version pipeline_v1 = Pipelines.get_specific_version( "538faa63-d204-46ff-aead-d158d0401cac", "0.1" ) -print(f"Original description: {pipeline_v1.description}") +print(f"Original description: {getattr(pipeline_v1.description, 'root', pipeline_v1.description)}") ``` ```java GET /v1/pipelines/{id}/versions -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Pipelines.getVersions("538faa63-d204-46ff-aead-d158d0401cac"); +EntityHistory history = client.pipelines().getVersionList("538faa63-d204-46ff-aead-d158d0401cac"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Pipelines.getSpecificVersion( - "538faa63-d204-46ff-aead-d158d0401cac", - 0.1 -); +Pipeline v1 = client.pipelines().getVersion("538faa63-d204-46ff-aead-d158d0401cac", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/search-indexes/create.mdx b/v1.13.x/api-reference/data-assets/search-indexes/create.mdx index 94f1064f7..e5e11eeed 100644 --- a/v1.13.x/api-reference/data-assets/search-indexes/create.mdx +++ b/v1.13.x/api-reference/data-assets/search-indexes/create.mdx @@ -16,7 +16,7 @@ Create a new search index within a search service. - Fully qualified name of the parent SearchService (e.g., `elasticsearch_sample`). + Fully qualified name of the parent SearchService, for example `elasticsearch_sample`. @@ -28,7 +28,7 @@ Create a new search index within a search service. - Data type of the field (e.g., `TEXT`, `KEYWORD`, `INT`, `OBJECT`). + Data type of the field, for example `TEXT`, `KEYWORD`, `INT`, `OBJECT`. @@ -58,7 +58,7 @@ Create a new search index within a search service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -67,8 +67,8 @@ Create a new search index within a search service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -80,11 +80,11 @@ Create a new search index within a search service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -116,19 +116,27 @@ request = CreateSearchIndexRequest( ) search_index = SearchIndexes.create(request) -print(f"Created: {search_index.fullyQualifiedName}") +print(f"Created: {search_index.fullyQualifiedName.root}") ``` ```java POST /v1/searchIndexes -import static org.openmetadata.sdk.fluent.SearchIndexes.*; - -// Create using builder pattern -var searchIndex = SearchIndexes.builder() - .name("table_search_index") - .displayName("TableSearchIndex") - .service("elasticsearch_sample") - .description("Search index for table entities") - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateSearchIndex; +import org.openmetadata.schema.entity.data.SearchIndex; +import org.openmetadata.schema.type.SearchIndexDataType; +import org.openmetadata.schema.type.SearchIndexField; +import org.openmetadata.sdk.fluent.SearchIndexes; + +CreateSearchIndex request = new CreateSearchIndex() + .withName("table_search_index") + .withDisplayName("TableSearchIndex") + .withService("elasticsearch_sample") + .withDescription("Search index for table entities") + .withFields(List.of( + new SearchIndexField().withName("name").withDataType(SearchIndexDataType.TEXT), + new SearchIndexField().withName("description").withDataType(SearchIndexDataType.TEXT))); + +SearchIndex searchIndex = SearchIndexes.create(request); ``` ```bash POST /v1/searchIndexes @@ -256,7 +264,7 @@ Returns the created search index object with all specified properties and system - Type of search service (e.g., ElasticSearch, OpenSearch). + Type of search service, for example ElasticSearch, OpenSearch. @@ -268,7 +276,7 @@ Returns the created search index object with all specified properties and system - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -290,11 +298,11 @@ Returns the created search index object with all specified properties and system - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/search-indexes/delete.mdx b/v1.13.x/api-reference/data-assets/search-indexes/delete.mdx index fbfc5c0a8..7ecbf9f86 100644 --- a/v1.13.x/api-reference/data-assets/search-indexes/delete.mdx +++ b/v1.13.x/api-reference/data-assets/search-indexes/delete.mdx @@ -28,7 +28,7 @@ Delete a search index by ID or fully qualified name. Supports soft delete (defau Use `DELETE /v1/searchIndexes/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the search index (e.g., `elasticsearch_sample.table_search_index`). + Fully qualified name of the search index, for example `elasticsearch_sample.table_search_index`. @@ -67,11 +67,13 @@ SearchIndexes.delete( ) # Delete by name -SearchIndexes.delete_by_name("elasticsearch_sample.table_search_index") +index = SearchIndexes.retrieve_by_name("elasticsearch_sample.table_search_index") +SearchIndexes.delete(index.id) # Delete by name with options -SearchIndexes.delete_by_name( - "elasticsearch_sample.table_search_index", +index = SearchIndexes.retrieve_by_name("elasticsearch_sample.table_search_index") +SearchIndexes.delete( + index.id, hard_delete=True ) @@ -80,22 +82,23 @@ SearchIndexes.restore("f5b0fa81-f241-4508-9219-dae31dcced18") ``` ```java DELETE /v1/searchIndexes/{id} -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.SearchIndex; + +// client is an initialized OpenMetadataClient. // Soft delete -SearchIndexes.delete("f5b0fa81-f241-4508-9219-dae31dcced18").execute(); +client.searchIndexes().delete("f5b0fa81-f241-4508-9219-dae31dcced18"); // Hard delete -SearchIndexes.delete("f5b0fa81-f241-4508-9219-dae31dcced18") - .hardDelete() - .execute(); +client.searchIndexes().delete("f5b0fa81-f241-4508-9219-dae31dcced18", Map.of("hardDelete", "true")); -// Delete by name -SearchIndexes.deleteByName("elasticsearch_sample.table_search_index") - .execute(); +// Delete by name (look up the ID first) +SearchIndex searchIndex = client.searchIndexes().getByName("elasticsearch_sample.table_search_index"); +client.searchIndexes().delete(searchIndex.getId()); // Restore -SearchIndexes.restore("f5b0fa81-f241-4508-9219-dae31dcced18"); +client.searchIndexes().restore("f5b0fa81-f241-4508-9219-dae31dcced18"); ``` ```bash DELETE /v1/searchIndexes/{id} diff --git a/v1.13.x/api-reference/data-assets/search-indexes/followers-votes.mdx b/v1.13.x/api-reference/data-assets/search-indexes/followers-votes.mdx index ecddf695b..155fe12de 100644 --- a/v1.13.x/api-reference/data-assets/search-indexes/followers-votes.mdx +++ b/v1.13.x/api-reference/data-assets/search-indexes/followers-votes.mdx @@ -51,47 +51,56 @@ Manage followers and votes for search index entities. ```python PUT /v1/searchIndexes/{id}/followers -from metadata.sdk import configure +from metadata.sdk import client, configure from metadata.sdk.entities import SearchIndexes configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client si_id = "f5b0fa81-f241-4508-9219-dae31dcced18" user_id = "user-uuid-here" # Add a follower si = SearchIndexes.add_followers(si_id, [user_id]) -print(f"Followers: {len(si.followers)}") +print(f"Followers: {len(si.followers.root)}") # Remove a follower si = SearchIndexes.remove_followers(si_id, [user_id]) # Add a vote -si = SearchIndexes.add_vote(si_id, vote_type="votedUp") +rest.put(f"/searchIndexes/{si_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -si = SearchIndexes.remove_vote(si_id) +rest.put(f"/searchIndexes/{si_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/searchIndexes/{id}/followers -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String siId = "f5b0fa81-f241-4508-9219-dae31dcced18"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -SearchIndexes.addFollower(siId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/searchIndexes/" + siId + "/followers", userId); // Remove a follower -SearchIndexes.removeFollower(siId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/searchIndexes/" + siId + "/followers/" + userId, null); // Add a vote -SearchIndexes.vote(siId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/searchIndexes/" + siId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -SearchIndexes.vote(siId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/searchIndexes/" + siId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/searchIndexes/{id}/followers diff --git a/v1.13.x/api-reference/data-assets/search-indexes/list.mdx b/v1.13.x/api-reference/data-assets/search-indexes/list.mdx index 091a72ac4..7da009e21 100644 --- a/v1.13.x/api-reference/data-assets/search-indexes/list.mdx +++ b/v1.13.x/api-reference/data-assets/search-indexes/list.mdx @@ -47,49 +47,52 @@ configure( # List first page indexes = SearchIndexes.list(limit=50) -for si in indexes.data: - print(f"{si.fullyQualifiedName}") +for si in indexes.entities: + print(f"{si.fullyQualifiedName.root}") # List all with auto-pagination for si in SearchIndexes.list_all(): - print(f"{si.fullyQualifiedName}") + print(f"{si.fullyQualifiedName.root}") # Filter by service indexes = SearchIndexes.list( - service="elasticsearch_sample", - fields=["owners", "tags", "domain"], + filters={"service": "elasticsearch_sample"}, + fields=["owners", "tags", "domains"], limit=50 ) -for si in indexes.data: - print(f"{si.fullyQualifiedName}") +for si in indexes.entities: + print(f"{si.fullyQualifiedName.root}") if si.owners: - print(f" Owners: {[o.name for o in si.owners]}") + print(f" Owners: {[o.name for o in si.owners.root]}") if si.tags: - print(f" Tags: {[t.tagFQN for t in si.tags]}") + print(f" Tags: {[tag.tagFQN.root for tag in si.tags]}") ``` ```java GET /v1/searchIndexes -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = SearchIndexes.list() - .limit(50) - .execute(); +ListResponse firstPage = client.searchIndexes().list(new ListParams().setLimit(50)); -for (var si : result.getData()) { - System.out.println(si.getFullyQualifiedName()); +for (SearchIndex item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = SearchIndexes.list() - .service("elasticsearch_sample") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var si : result.getData()) { - System.out.println(si.getFullyQualifiedName()); +ListResponse filtered = client.searchIndexes().list( + new ListParams() + .setService("elasticsearch_sample") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (SearchIndex item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -179,7 +182,7 @@ Returns a paginated list of search index objects. By default, only basic fields - Type of search service (e.g., ElasticSearch, OpenSearch). + Type of search service, for example ElasticSearch, OpenSearch. diff --git a/v1.13.x/api-reference/data-assets/search-indexes/retrieve.mdx b/v1.13.x/api-reference/data-assets/search-indexes/retrieve.mdx index 3e9115922..21218be93 100644 --- a/v1.13.x/api-reference/data-assets/search-indexes/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/search-indexes/retrieve.mdx @@ -16,7 +16,7 @@ Get a single search index by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single search index by its unique ID or fully qualified name. Use `GET /v1/searchIndexes/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the search index (e.g., `elasticsearch_sample.table_search_index`). + Fully qualified name of the search index, for example `elasticsearch_sample.table_search_index`. @@ -51,7 +51,7 @@ configure( # Get by ID si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18") -print(f"{si.fullyQualifiedName}: {si.description}") +print(f"{si.fullyQualifiedName.root}: {getattr(si.description, 'root', si.description)}") # Get by ID with fields si = SearchIndexes.retrieve( @@ -65,31 +65,31 @@ si = SearchIndexes.retrieve_by_name("elasticsearch_sample.table_search_index") # Get by name with fields si = SearchIndexes.retrieve_by_name( "elasticsearch_sample.table_search_index", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/searchIndexes/{id} -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; + +// client is an initialized OpenMetadataClient. // Get by ID -var si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18"); +SearchIndex searchIndex = client.searchIndexes().get("f5b0fa81-f241-4508-9219-dae31dcced18"); // Get by ID with fields -var si = SearchIndexes.retrieve( +SearchIndex searchIndexWithFields = client.searchIndexes().get( "f5b0fa81-f241-4508-9219-dae31dcced18", "owners,tags,fields" ); // Get by fully qualified name -var si = SearchIndexes.retrieveByName( - "elasticsearch_sample.table_search_index" -); +SearchIndex searchIndexByName = client.searchIndexes().getByName("elasticsearch_sample.table_search_index"); // Get by name with fields -var si = SearchIndexes.retrieveByName( +SearchIndex searchIndexByNameWithFields = client.searchIndexes().getByName( "elasticsearch_sample.table_search_index", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -220,7 +220,7 @@ Returns a search index object with all requested fields populated. - Type of search service (e.g., ElasticSearch, OpenSearch). + Type of search service, for example ElasticSearch, OpenSearch. diff --git a/v1.13.x/api-reference/data-assets/search-indexes/update.mdx b/v1.13.x/api-reference/data-assets/search-indexes/update.mdx index 14626c8fb..cc837b01f 100644 --- a/v1.13.x/api-reference/data-assets/search-indexes/update.mdx +++ b/v1.13.x/api-reference/data-assets/search-indexes/update.mdx @@ -20,7 +20,7 @@ Update a search index's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/searchIndexes/name/{fqn}` to update by fully qualified name. - Fully qualified name of the search index (e.g., `elasticsearch_sample.table_search_index`). + Fully qualified name of the search index, for example `elasticsearch_sample.table_search_index`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,17 +58,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -90,16 +90,18 @@ si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18") si.description = "Updated: Search index for table entities with enhanced mapping" updated = SearchIndexes.update(si) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/searchIndexes/{id} -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18"); -si.setDescription("Updated: Search index for table entities with enhanced mapping"); -var updated = SearchIndexes.update(si); +SearchIndex searchIndex = client.searchIndexes().get("f5b0fa81-f241-4508-9219-dae31dcced18"); +searchIndex.setDescription("Updated: Search index for table entities with enhanced mapping"); +SearchIndex updated = client.searchIndexes().update(searchIndex.getId(), searchIndex); ``` ```bash PATCH /v1/searchIndexes/{id} diff --git a/v1.13.x/api-reference/data-assets/search-indexes/versions.mdx b/v1.13.x/api-reference/data-assets/search-indexes/versions.mdx index 9e36a2bcc..f62acaace 100644 --- a/v1.13.x/api-reference/data-assets/search-indexes/versions.mdx +++ b/v1.13.x/api-reference/data-assets/search-indexes/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/searchIndexes/{id}/versions/{version}` to retrieve a specific versi - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/searchIndexes/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import SearchIndexes @@ -40,31 +42,32 @@ configure( # List all versions versions = SearchIndexes.get_versions("f5b0fa81-f241-4508-9219-dae31dcced18") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version si_v1 = SearchIndexes.get_specific_version( "f5b0fa81-f241-4508-9219-dae31dcced18", "0.1" ) -print(f"Original description: {si_v1.description}") +print(f"Original description: {getattr(si_v1.description, 'root', si_v1.description)}") ``` ```java GET /v1/searchIndexes/{id}/versions -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = SearchIndexes.getVersions("f5b0fa81-f241-4508-9219-dae31dcced18"); +EntityHistory history = client.searchIndexes().getVersionList("f5b0fa81-f241-4508-9219-dae31dcced18"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = SearchIndexes.getSpecificVersion( - "f5b0fa81-f241-4508-9219-dae31dcced18", - 0.1 -); +SearchIndex v1 = client.searchIndexes().getVersion("f5b0fa81-f241-4508-9219-dae31dcced18", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/storage-services/create.mdx b/v1.13.x/api-reference/data-assets/storage-services/create.mdx index 54fcd1fb8..5ae74b3fd 100644 --- a/v1.13.x/api-reference/data-assets/storage-services/create.mdx +++ b/v1.13.x/api-reference/data-assets/storage-services/create.mdx @@ -16,7 +16,7 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Type of storage service (e.g., `S3`, `GCS`, `ADLS`, `CustomStorage`). + Type of storage service, for example `S3`, `GCS`, `ADLS`, `CustomStorage`. @@ -24,7 +24,7 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Service-specific connection configuration (e.g., AWS credentials for S3, project ID for GCS). + Service-specific connection configuration, for example AWS credentials for S3, project ID for GCS. @@ -46,7 +46,7 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -107,20 +107,29 @@ request = CreateStorageServiceRequest( ) service = StorageServices.create(request) -print(f"Created: {service.fullyQualifiedName}") +print(f"Created: {service.fullyQualifiedName.root}") ``` ```java POST /v1/services/storageServices -import static org.openmetadata.sdk.fluent.StorageServices.*; - -StorageService service = StorageServices.builder() - .name("s3_datalake") - .serviceType("S3") - .connection(s3Connection() - .awsAccessKeyId("AKIA...") - .awsSecretAccessKey("***") - .awsRegion("us-east-1")) - .create(); +import org.openmetadata.schema.api.services.CreateStorageService; +import org.openmetadata.schema.api.services.CreateStorageService.StorageServiceType; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.schema.security.credentials.AWSCredentials; +import org.openmetadata.schema.services.connections.storage.S3Connection; +import org.openmetadata.schema.type.StorageConnection; +import org.openmetadata.sdk.fluent.StorageServices; + +CreateStorageService request = new CreateStorageService() + .withName("s3_datalake") + .withServiceType(StorageServiceType.S3) + .withConnection(new StorageConnection().withConfig( + new S3Connection().withAwsConfig( + new AWSCredentials() + .withAwsAccessKeyId("AKIA...") + .withAwsSecretAccessKey("***") + .withAwsRegion("us-east-1")))); + +StorageService service = StorageServices.create(request); ``` ```bash POST /v1/services/storageServices @@ -207,7 +216,7 @@ Returns the created storage service object with all specified properties and sys - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -229,7 +238,7 @@ Returns the created storage service object with all specified properties and sys - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -238,7 +247,7 @@ Returns the created storage service object with all specified properties and sys - + Fully qualified name of the assigned domain. @@ -251,11 +260,11 @@ Returns the created storage service object with all specified properties and sys - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/storage-services/delete.mdx b/v1.13.x/api-reference/data-assets/storage-services/delete.mdx index a0d07c59b..89cab6fac 100644 --- a/v1.13.x/api-reference/data-assets/storage-services/delete.mdx +++ b/v1.13.x/api-reference/data-assets/storage-services/delete.mdx @@ -28,7 +28,7 @@ Delete a storage service by ID or fully qualified name. Supports soft delete (de Use `DELETE /v1/services/storageServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the storage service (e.g., `s3_datalake`). + Fully qualified name of the storage service, for example `s3_datalake`. @@ -67,11 +67,11 @@ StorageServices.delete( ) # Delete by name -StorageServices.delete_by_name("s3_datalake") +StorageServices.delete(StorageServices.retrieve_by_name("s3_datalake").id) # Delete by name with options -StorageServices.delete_by_name( - "s3_datalake", +StorageServices.delete( + StorageServices.retrieve_by_name("s3_datalake").id, hard_delete=True, recursive=True ) @@ -81,7 +81,10 @@ StorageServices.restore("d1589e1d-2ab0-431c-a383-15e4be20a106") ``` ```java DELETE /v1/services/storageServices/{id} -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.fluent.StorageServices; + +// client is an initialized OpenMetadataClient. // Soft delete StorageServices.delete("d1589e1d-2ab0-431c-a383-15e4be20a106").execute(); @@ -91,11 +94,12 @@ StorageServices.delete("d1589e1d-2ab0-431c-a383-15e4be20a106") .hardDelete() .execute(); -// Delete by name -StorageServices.deleteByName("s3_datalake").execute(); +// Delete by name (look up the ID first) +StorageService service = StorageServices.retrieveByName("s3_datalake"); +StorageServices.delete(service.getId()).execute(); -// Restore -StorageServices.restore("d1589e1d-2ab0-431c-a383-15e4be20a106"); +// Restore. The fluent class has no restore method, so use the client service. +client.storageServices().restore("d1589e1d-2ab0-431c-a383-15e4be20a106"); ``` ```bash DELETE /v1/services/storageServices/{id} diff --git a/v1.13.x/api-reference/data-assets/storage-services/list.mdx b/v1.13.x/api-reference/data-assets/storage-services/list.mdx index 2d7378506..9a296fed8 100644 --- a/v1.13.x/api-reference/data-assets/storage-services/list.mdx +++ b/v1.13.x/api-reference/data-assets/storage-services/list.mdx @@ -43,12 +43,12 @@ configure( # List first page services = StorageServices.list(limit=50) -for svc in services.data: - print(f"{svc.fullyQualifiedName} ({svc.serviceType})") +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root} ({svc.serviceType})") # List all with auto-pagination for svc in StorageServices.list_all(): - print(f"{svc.fullyQualifiedName}") + print(f"{svc.fullyQualifiedName.root}") # List with fields services = StorageServices.list( @@ -56,33 +56,30 @@ services = StorageServices.list( limit=50 ) -for svc in services.data: - print(f"{svc.fullyQualifiedName}") +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root}") if svc.owners: - print(f" Owners: {[o.name for o in svc.owners]}") + print(f" Owners: {[o.name for o in svc.owners.root]}") ``` ```java GET /v1/services/storageServices -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = StorageServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.storageServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (StorageService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } -// List with fields -var result = StorageServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); -} +// With fields +ListResponse withFields = client.storageServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/storageServices @@ -165,7 +162,7 @@ Returns a paginated list of storage service objects. By default, only basic fiel - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. diff --git a/v1.13.x/api-reference/data-assets/storage-services/retrieve.mdx b/v1.13.x/api-reference/data-assets/storage-services/retrieve.mdx index 7ee640325..56392dc50 100644 --- a/v1.13.x/api-reference/data-assets/storage-services/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/storage-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single storage service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single storage service by its unique ID or fully qualified name. Use `GET /v1/services/storageServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the storage service (e.g., `s3_datalake`). + Fully qualified name of the storage service, for example `s3_datalake`. @@ -51,7 +51,7 @@ configure( # Get by ID svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106") -print(f"{svc.fullyQualifiedName}: {svc.serviceType}") +print(f"{svc.fullyQualifiedName.root}: {svc.serviceType}") # Get by ID with fields svc = StorageServices.retrieve( @@ -70,22 +70,23 @@ svc = StorageServices.retrieve_by_name( ``` ```java GET /v1/services/storageServices/{id} -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.fluent.StorageServices; // Get by ID -var svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); +StorageService service = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); // Get by ID with fields -var svc = StorageServices.retrieve( +StorageService serviceWithFields = StorageServices.retrieve( "d1589e1d-2ab0-431c-a383-15e4be20a106", "owners,tags" ); // Get by fully qualified name -var svc = StorageServices.retrieveByName("s3_datalake"); +StorageService serviceByName = StorageServices.retrieveByName("s3_datalake"); // Get by name with fields -var svc = StorageServices.retrieveByName("s3_datalake", "owners,tags,domains"); +StorageService serviceByNameWithFields = StorageServices.retrieveByName("s3_datalake", "owners,tags,domains"); ``` ```bash GET /v1/services/storageServices/{id} @@ -168,7 +169,7 @@ Returns a storage service object with all requested fields populated. - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. diff --git a/v1.13.x/api-reference/data-assets/storage-services/update.mdx b/v1.13.x/api-reference/data-assets/storage-services/update.mdx index 8c583953e..d724d7f54 100644 --- a/v1.13.x/api-reference/data-assets/storage-services/update.mdx +++ b/v1.13.x/api-reference/data-assets/storage-services/update.mdx @@ -20,7 +20,7 @@ Update a storage service's properties using JSON Merge Patch. You can update by Use `PATCH /v1/services/storageServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the storage service (e.g., `s3_datalake`). + Fully qualified name of the storage service, for example `s3_datalake`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -96,16 +96,17 @@ svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106") svc.description = "Updated: Production S3 data lake with new region configuration" updated = StorageServices.update(svc) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/services/storageServices/{id} -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.fluent.StorageServices; // Retrieve, modify, and update -var svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); -svc.setDescription("Updated: Production S3 data lake with new region configuration"); -var updated = StorageServices.update(svc); +StorageService service = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); +service.setDescription("Updated: Production S3 data lake with new region configuration"); +StorageService updated = StorageServices.update(service); ``` ```bash PATCH /v1/services/storageServices/{id} diff --git a/v1.13.x/api-reference/data-assets/storage-services/versions.mdx b/v1.13.x/api-reference/data-assets/storage-services/versions.mdx index 9863d95dd..acca64ece 100644 --- a/v1.13.x/api-reference/data-assets/storage-services/versions.mdx +++ b/v1.13.x/api-reference/data-assets/storage-services/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/services/storageServices/{id}/versions/{version}` to retrieve a spe - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/services/storageServices/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import StorageServices @@ -40,31 +42,32 @@ configure( # List all versions versions = StorageServices.get_versions("d1589e1d-2ab0-431c-a383-15e4be20a106") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version svc_v1 = StorageServices.get_specific_version( "d1589e1d-2ab0-431c-a383-15e4be20a106", "0.1" ) -print(f"Original description: {svc_v1.description}") +print(f"Original description: {getattr(svc_v1.description, 'root', svc_v1.description)}") ``` ```java GET /v1/services/storageServices/{id}/versions -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = StorageServices.getVersions("d1589e1d-2ab0-431c-a383-15e4be20a106"); +EntityHistory history = client.storageServices().getVersionList("d1589e1d-2ab0-431c-a383-15e4be20a106"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = StorageServices.getSpecificVersion( - "d1589e1d-2ab0-431c-a383-15e4be20a106", - 0.1 -); +StorageService v1 = client.storageServices().getVersion("d1589e1d-2ab0-431c-a383-15e4be20a106", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/stored-procedures/create.mdx b/v1.13.x/api-reference/data-assets/stored-procedures/create.mdx index 9823729c4..bd0477ff2 100644 --- a/v1.13.x/api-reference/data-assets/stored-procedures/create.mdx +++ b/v1.13.x/api-reference/data-assets/stored-procedures/create.mdx @@ -16,7 +16,7 @@ Create a new stored procedure within a database schema. - Fully qualified name of the parent DatabaseSchema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the parent DatabaseSchema, for example `snowflake_prod.analytics.public`. @@ -28,7 +28,7 @@ Create a new stored procedure within a database schema. - Programming language of the code (e.g., `SQL`, `JavaScript`, `Python`). + Programming language of the code, for example `SQL`, `JavaScript`, `Python`. @@ -50,7 +50,7 @@ Create a new stored procedure within a database schema. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -59,8 +59,8 @@ Create a new stored procedure within a database schema. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -72,11 +72,11 @@ Create a new stored procedure within a database schema. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -108,19 +108,27 @@ request = CreateStoredProcedureRequest( ) stored_procedure = StoredProcedures.create(request) -print(f"Created: {stored_procedure.fullyQualifiedName}") +print(f"Created: {stored_procedure.fullyQualifiedName.root}") ``` ```java POST /v1/storedProcedures -import static org.openmetadata.sdk.fluent.StoredProcedures.*; - -// Create using builder pattern -var storedProcedure = StoredProcedures.builder() - .name("usp_refresh_analytics") - .displayName("Refresh Analytics") - .databaseSchema("snowflake_prod.analytics.public") - .description("Refreshes materialized analytics views nightly") - .create(); +import org.openmetadata.schema.api.data.CreateStoredProcedure; +import org.openmetadata.schema.entity.data.StoredProcedure; +import org.openmetadata.schema.api.data.StoredProcedureCode; +import org.openmetadata.schema.type.StoredProcedureLanguage; + +// client is an initialized OpenMetadataClient. + +CreateStoredProcedure request = new CreateStoredProcedure() + .withName("usp_refresh_analytics") + .withDisplayName("Refresh Analytics") + .withDatabaseSchema("snowflake_prod.analytics.public") + .withDescription("Refreshes materialized analytics views nightly") + .withStoredProcedureCode(new StoredProcedureCode() + .withCode("CREATE OR REPLACE PROCEDURE usp_refresh_analytics() ...") + .withLanguage(StoredProcedureLanguage.SQL)); + +StoredProcedure storedProcedure = client.storedProcedures().create(request); ``` ```bash POST /v1/storedProcedures @@ -249,7 +257,7 @@ Returns the created stored procedure object with all specified properties and sy - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -261,7 +269,7 @@ Returns the created stored procedure object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -283,11 +291,11 @@ Returns the created stored procedure object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/stored-procedures/delete.mdx b/v1.13.x/api-reference/data-assets/stored-procedures/delete.mdx index 2826b70d1..e2bcf6ae7 100644 --- a/v1.13.x/api-reference/data-assets/stored-procedures/delete.mdx +++ b/v1.13.x/api-reference/data-assets/stored-procedures/delete.mdx @@ -28,7 +28,7 @@ Delete a stored procedure by ID or fully qualified name. Supports soft delete (d Use `DELETE /v1/storedProcedures/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the stored procedure (e.g., `snowflake_prod.analytics.public.usp_refresh_analytics`). + Fully qualified name of the stored procedure, for example `snowflake_prod.analytics.public.usp_refresh_analytics`. @@ -66,36 +66,40 @@ StoredProcedures.delete( hard_delete=True ) -# Delete by name -StoredProcedures.delete_by_name("snowflake_prod.analytics.public.usp_refresh_analytics") +# Delete by name (look up the ID first) +entity = StoredProcedures.retrieve_by_name("snowflake_prod.analytics.public.usp_refresh_analytics") +StoredProcedures.delete(entity.id) # Delete by name with options -StoredProcedures.delete_by_name( - "snowflake_prod.analytics.public.usp_refresh_analytics", - hard_delete=True -) +entity = StoredProcedures.retrieve_by_name("snowflake_prod.analytics.public.usp_refresh_analytics") +StoredProcedures.delete(entity.id, hard_delete=True) # Restore a soft-deleted stored procedure StoredProcedures.restore("770e8400-e29b-41d4-a716-446655440000") ``` ```java DELETE /v1/storedProcedures/{id} -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -StoredProcedures.delete("770e8400-e29b-41d4-a716-446655440000").execute(); +client.storedProcedures().delete("770e8400-e29b-41d4-a716-446655440000"); // Hard delete -StoredProcedures.delete("770e8400-e29b-41d4-a716-446655440000") - .hardDelete() - .execute(); +client.storedProcedures().delete("770e8400-e29b-41d4-a716-446655440000", Map.of("hardDelete", "true")); // Delete by name -StoredProcedures.deleteByName("snowflake_prod.analytics.public.usp_refresh_analytics") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/storedProcedures/name/snowflake_prod.analytics.public.usp_refresh_analytics", + null, + Void.class +); // Restore -StoredProcedures.restore("770e8400-e29b-41d4-a716-446655440000"); +client.storedProcedures().restore("770e8400-e29b-41d4-a716-446655440000"); ``` ```bash DELETE /v1/storedProcedures/{id} diff --git a/v1.13.x/api-reference/data-assets/stored-procedures/followers-votes.mdx b/v1.13.x/api-reference/data-assets/stored-procedures/followers-votes.mdx index 172f5849f..4376c0aad 100644 --- a/v1.13.x/api-reference/data-assets/stored-procedures/followers-votes.mdx +++ b/v1.13.x/api-reference/data-assets/stored-procedures/followers-votes.mdx @@ -51,7 +51,7 @@ Manage followers and votes for stored procedure entities. ```python PUT /v1/storedProcedures/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import StoredProcedures configure( @@ -59,39 +59,62 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + sp_id = "770e8400-e29b-41d4-a716-446655440000" user_id = "user-uuid-here" # Add a follower sp = StoredProcedures.add_followers(sp_id, [user_id]) -print(f"Followers: {len(sp.followers)}") +print(f"Followers: {len(sp.followers.root)}") # Remove a follower sp = StoredProcedures.remove_followers(sp_id, [user_id]) # Add a vote -sp = StoredProcedures.add_vote(sp_id, vote_type="votedUp") +rest.put(f"/storedProcedures/{sp_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -sp = StoredProcedures.remove_vote(sp_id) +rest.put(f"/storedProcedures/{sp_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/storedProcedures/{id}/followers -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String spId = "770e8400-e29b-41d4-a716-446655440000"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; // Add a follower -StoredProcedures.addFollower(spId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/storedProcedures/" + spId + "/followers", + UUID.fromString(userId) +); // Remove a follower -StoredProcedures.removeFollower(spId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/storedProcedures/" + spId + "/followers/" + userId, + null +); // Add a vote -StoredProcedures.vote(spId, "votedUp"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/storedProcedures/" + spId + "/vote", + Map.of("updatedVoteType", "votedUp") +); // Remove a vote -StoredProcedures.vote(spId, "unVoted"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/storedProcedures/" + spId + "/vote", + Map.of("updatedVoteType", "unVoted") +); ``` ```bash PUT /v1/storedProcedures/{id}/followers diff --git a/v1.13.x/api-reference/data-assets/stored-procedures/list.mdx b/v1.13.x/api-reference/data-assets/stored-procedures/list.mdx index 6ddfef431..60af92a49 100644 --- a/v1.13.x/api-reference/data-assets/stored-procedures/list.mdx +++ b/v1.13.x/api-reference/data-assets/stored-procedures/list.mdx @@ -51,48 +51,53 @@ configure( # List first page procedures = StoredProcedures.list(limit=50) -for sp in procedures.data: - print(f"{sp.fullyQualifiedName}") +for sp in procedures.entities: + print(f"{sp.fullyQualifiedName.root}") # List all with auto-pagination for sp in StoredProcedures.list_all(): - print(f"{sp.fullyQualifiedName}") + print(f"{sp.fullyQualifiedName.root}") # Filter by database schema procedures = StoredProcedures.list( - databaseSchema="snowflake_prod.analytics.public", - fields=["owners", "tags", "domain"], + filters={"databaseSchema": "snowflake_prod.analytics.public"}, + fields=["owners", "tags", "domains"], limit=50 ) -for sp in procedures.data: - print(f"{sp.fullyQualifiedName}") +for sp in procedures.entities: + print(f"{sp.fullyQualifiedName.root}") if sp.owners: - print(f" Owners: {[o.name for o in sp.owners]}") + print(f" Owners: {[o.name for o in sp.owners.root]}") if sp.tags: - print(f" Tags: {[t.tagFQN for t in sp.tags]}") + print(f" Tags: {[t.tagFQN.root for t in sp.tags]}") ``` ```java GET /v1/storedProcedures -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.StoredProcedure; + +// client is an initialized OpenMetadataClient. // List first page -var result = StoredProcedures.list() - .limit(50) - .execute(); +ListResponse firstPage = client.storedProcedures().list( + new ListParams().setLimit(50) +); -for (var sp : result.getData()) { +for (StoredProcedure sp : firstPage.getData()) { System.out.println(sp.getFullyQualifiedName()); } // Filter by database schema with fields -var result = StoredProcedures.list() - .databaseSchema("snowflake_prod.analytics.public") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var sp : result.getData()) { +ListResponse filtered = client.storedProcedures().list( + new ListParams() + .setDatabaseSchema("snowflake_prod.analytics.public") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (StoredProcedure sp : filtered.getData()) { System.out.println(sp.getFullyQualifiedName()); } ``` @@ -199,7 +204,7 @@ Returns a paginated list of stored procedure objects. By default, only basic fie - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v1.13.x/api-reference/data-assets/stored-procedures/retrieve.mdx b/v1.13.x/api-reference/data-assets/stored-procedures/retrieve.mdx index d4707331f..3a75248e9 100644 --- a/v1.13.x/api-reference/data-assets/stored-procedures/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/stored-procedures/retrieve.mdx @@ -16,7 +16,7 @@ Get a single stored procedure by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single stored procedure by its unique ID or fully qualified name. Use `GET /v1/storedProcedures/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the stored procedure (e.g., `snowflake_prod.analytics.public.usp_refresh_analytics`). + Fully qualified name of the stored procedure, for example `snowflake_prod.analytics.public.usp_refresh_analytics`. @@ -51,7 +51,7 @@ configure( # Get by ID sp = StoredProcedures.retrieve("770e8400-e29b-41d4-a716-446655440000") -print(f"{sp.fullyQualifiedName}: {sp.description}") +print(f"{sp.fullyQualifiedName.root}: {sp.name.root}") # Get by ID with fields sp = StoredProcedures.retrieve( @@ -65,31 +65,33 @@ sp = StoredProcedures.retrieve_by_name("snowflake_prod.analytics.public.usp_refr # Get by name with fields sp = StoredProcedures.retrieve_by_name( "snowflake_prod.analytics.public.usp_refresh_analytics", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/storedProcedures/{id} -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.schema.entity.data.StoredProcedure; + +// client is an initialized OpenMetadataClient. // Get by ID -var sp = StoredProcedures.retrieve("770e8400-e29b-41d4-a716-446655440000"); +StoredProcedure sp = client.storedProcedures().get("770e8400-e29b-41d4-a716-446655440000"); // Get by ID with fields -var sp = StoredProcedures.retrieve( +StoredProcedure spWithFields = client.storedProcedures().get( "770e8400-e29b-41d4-a716-446655440000", "owners,tags,storedProcedureCode" ); // Get by fully qualified name -var sp = StoredProcedures.retrieveByName( +StoredProcedure spByName = client.storedProcedures().getByName( "snowflake_prod.analytics.public.usp_refresh_analytics" ); // Get by name with fields -var sp = StoredProcedures.retrieveByName( +StoredProcedure spByNameWithFields = client.storedProcedures().getByName( "snowflake_prod.analytics.public.usp_refresh_analytics", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -223,7 +225,7 @@ Returns a stored procedure object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v1.13.x/api-reference/data-assets/stored-procedures/update.mdx b/v1.13.x/api-reference/data-assets/stored-procedures/update.mdx index 75a05d6e5..3335fb00a 100644 --- a/v1.13.x/api-reference/data-assets/stored-procedures/update.mdx +++ b/v1.13.x/api-reference/data-assets/stored-procedures/update.mdx @@ -20,7 +20,7 @@ Update a stored procedure's properties using JSON Merge Patch. You can update by Use `PATCH /v1/storedProcedures/name/{fqn}` to update by fully qualified name. - Fully qualified name of the stored procedure (e.g., `snowflake_prod.analytics.public.usp_refresh_analytics`). + Fully qualified name of the stored procedure, for example `snowflake_prod.analytics.public.usp_refresh_analytics`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Programming language of the code (e.g., `SQL`, `JavaScript`, `Python`). + Programming language of the code, for example `SQL`, `JavaScript`, `Python`. @@ -58,7 +58,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -72,17 +72,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -108,16 +108,18 @@ sp.storedProcedureCode = { } updated = StoredProcedures.update(sp) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/storedProcedures/{id} -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.schema.entity.data.StoredProcedure; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var sp = StoredProcedures.retrieve("770e8400-e29b-41d4-a716-446655440000"); +StoredProcedure sp = client.storedProcedures().get("770e8400-e29b-41d4-a716-446655440000"); sp.setDescription("Updated: Refreshes materialized analytics views with incremental logic"); -var updated = StoredProcedures.update(sp); +StoredProcedure updated = client.storedProcedures().update("770e8400-e29b-41d4-a716-446655440000", sp); ``` ```bash PATCH /v1/storedProcedures/{id} diff --git a/v1.13.x/api-reference/data-assets/stored-procedures/versions.mdx b/v1.13.x/api-reference/data-assets/stored-procedures/versions.mdx index 3630b6d61..7c2211c3d 100644 --- a/v1.13.x/api-reference/data-assets/stored-procedures/versions.mdx +++ b/v1.13.x/api-reference/data-assets/stored-procedures/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/storedProcedures/{id}/versions/{version}` to retrieve a specific ve - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/storedProcedures/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import StoredProcedures @@ -40,28 +42,30 @@ configure( # List all versions versions = StoredProcedures.get_versions("770e8400-e29b-41d4-a716-446655440000") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version sp_v1 = StoredProcedures.get_specific_version( "770e8400-e29b-41d4-a716-446655440000", "0.1" ) -print(f"Original description: {sp_v1.description}") +print(f"Original description: {sp_v1.description.root if sp_v1.description else None}") ``` ```java GET /v1/storedProcedures/{id}/versions -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.schema.entity.data.StoredProcedure; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = StoredProcedures.getVersions("770e8400-e29b-41d4-a716-446655440000"); +EntityHistory history = client.storedProcedures().getVersionList("770e8400-e29b-41d4-a716-446655440000"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = StoredProcedures.getSpecificVersion( +StoredProcedure v1 = client.storedProcedures().getVersion( "770e8400-e29b-41d4-a716-446655440000", 0.1 ); diff --git a/v1.13.x/api-reference/data-assets/tables/create.mdx b/v1.13.x/api-reference/data-assets/tables/create.mdx index 6f1b9e302..5c2bf4c12 100644 --- a/v1.13.x/api-reference/data-assets/tables/create.mdx +++ b/v1.13.x/api-reference/data-assets/tables/create.mdx @@ -16,7 +16,7 @@ Create a new table within a database schema. - Fully qualified name of the parent DatabaseSchema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the parent DatabaseSchema, for example `snowflake_prod.analytics.public`. @@ -28,7 +28,7 @@ Create a new table within a database schema. - Data type of the column (e.g., `INT`, `VARCHAR`, `TIMESTAMP`, `BOOLEAN`, `ARRAY`, `MAP`). + Data type of the column, for example `INT`, `VARCHAR`, `TIMESTAMP`, `BOOLEAN`, `ARRAY`, `MAP`. @@ -36,7 +36,7 @@ Create a new table within a database schema. - Length of the data type (e.g., `256` for `VARCHAR(256)`). + Length of the data type, for example `256` for `VARCHAR(256`). @@ -62,7 +62,7 @@ Create a new table within a database schema. - Data retention period in ISO 8601 duration format (e.g., `P365D`). + Data retention period in ISO 8601 duration format, for example `P365D`. @@ -74,7 +74,7 @@ Create a new table within a database schema. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -83,8 +83,8 @@ Create a new table within a database schema. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -96,11 +96,11 @@ Create a new table within a database schema. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -131,21 +131,23 @@ request = CreateTableRequest( ) table = Tables.create(request) -print(f"Created: {table.fullyQualifiedName}") +print(f"Created: {table.fullyQualifiedName.root}") ``` ```java POST /v1/tables -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.fluent.builders.ColumnBuilder; +import org.openmetadata.sdk.fluent.builders.TableBuilder; -Table table = Tables.builder() +Table table = new TableBuilder(client) .name("customers") - .databaseSchema("snowflake_prod.analytics.public") - .columns(List.of( - column("id", "INT").constraint("PRIMARY_KEY"), - column("name", "VARCHAR").dataLength(256), - column("email", "VARCHAR").dataLength(256), - column("created_at", "TIMESTAMP") - )) + .schemaFQN("snowflake_prod.analytics.public") + .columns( + ColumnBuilder.integer("id").primaryKey(), + ColumnBuilder.varchar("name", 256), + ColumnBuilder.varchar("email", 256), + ColumnBuilder.timestamp("created_at") + ) .create(); ``` @@ -265,7 +267,7 @@ Returns the created table object with all specified properties, system-generated - Type of table (e.g., `Regular`, `View`, `MaterializedView`). + Type of table, for example `Regular`, `View`, `MaterializedView`. @@ -303,7 +305,7 @@ Returns the created table object with all specified properties, system-generated - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v1.13.x/api-reference/data-assets/tables/custom-metrics.mdx b/v1.13.x/api-reference/data-assets/tables/custom-metrics.mdx index fa3bc2a23..36f8e912f 100644 --- a/v1.13.x/api-reference/data-assets/tables/custom-metrics.mdx +++ b/v1.13.x/api-reference/data-assets/tables/custom-metrics.mdx @@ -37,6 +37,8 @@ Define custom SQL-based metrics on a table or specific column. Custom metrics ar `DELETE /v1/tables/{id}/customMetric/{metricName}` +To delete a column-level metric, use `DELETE /v1/tables/{id}/customMetric/{columnName}/{metricName}`. + UUID of the table. @@ -47,57 +49,68 @@ Define custom SQL-based metrics on a table or specific column. Custom metrics ar ```python PUT /v1/tables/{id}/customMetric -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Tables +from metadata.generated.schema.api.tests.createCustomMetric import CreateCustomMetricRequest configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add a table-level custom metric -Tables.add_custom_metric(table_id, { - "name": "active_customer_ratio", - "description": "Ratio of active customers to total customers", - "expression": "SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}" -}) +Tables.add_custom_metric(table_id, CreateCustomMetricRequest( + name="active_customer_ratio", + description="Ratio of active customers to total customers", + expression="SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}" +)) # Add a column-level custom metric -Tables.add_custom_metric(table_id, { - "name": "email_domain_count", - "description": "Number of distinct email domains", - "columnName": "email", - "expression": "SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}" -}) - -# Delete a custom metric -Tables.delete_custom_metric(table_id, "active_customer_ratio") +Tables.add_custom_metric(table_id, CreateCustomMetricRequest( + name="email_domain_count", + description="Number of distinct email domains", + columnName="email", + expression="SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}" +)) + +# Delete a table-level custom metric +rest.delete(f"/tables/{table_id}/customMetric/active_customer_ratio") + +# Delete a column-level custom metric +rest.delete(f"/tables/{table_id}/customMetric/email/email_domain_count") ``` ```java PUT /v1/tables/{id}/customMetric -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.tests.CustomMetric; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Add a table-level custom metric -Tables.addCustomMetric(tableId, Map.of( - "name", "active_customer_ratio", - "description", "Ratio of active customers to total customers", - "expression", "SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}" -)); +CustomMetric tableMetric = new CustomMetric() + .withName("active_customer_ratio") + .withDescription("Ratio of active customers to total customers") + .withExpression("SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}"); +client.tables().updateCustomMetric(tableId, tableMetric); // Add a column-level custom metric -Tables.addCustomMetric(tableId, Map.of( - "name", "email_domain_count", - "description", "Number of distinct email domains", - "columnName", "email", - "expression", "SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}" -)); - -// Delete a custom metric -Tables.deleteCustomMetric(tableId, "active_customer_ratio"); +CustomMetric columnMetric = new CustomMetric() + .withName("email_domain_count") + .withDescription("Number of distinct email domains") + .withColumnName("email") + .withExpression("SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}"); +client.tables().updateCustomMetric(tableId, columnMetric); + +// Delete a table-level custom metric +client.tables().deleteCustomMetric(tableId, "active_customer_ratio"); + +// Delete a column-level custom metric +client.tables().deleteCustomMetric(tableId, "email/email_domain_count"); ``` ```bash PUT /v1/tables/{id}/customMetric diff --git a/v1.13.x/api-reference/data-assets/tables/delete.mdx b/v1.13.x/api-reference/data-assets/tables/delete.mdx index 7e1167cf9..73e2d1744 100644 --- a/v1.13.x/api-reference/data-assets/tables/delete.mdx +++ b/v1.13.x/api-reference/data-assets/tables/delete.mdx @@ -28,7 +28,7 @@ Delete a table by ID or fully qualified name. Supports soft delete (default), ha Use `DELETE /v1/tables/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. @@ -67,24 +67,24 @@ Tables.delete( hard_delete=True ) -# Delete by name -Tables.delete_by_name("snowflake_prod.analytics.public.customers") +# Delete by name (look up the ID first) +entity = Tables.retrieve_by_name("snowflake_prod.analytics.public.customers") +Tables.delete(entity.id) # Restore a soft-deleted table Tables.restore("a1b2c3d4-e5f6-7890-abcd-ef1234567890") ``` ```java DELETE /v1/tables/{id} -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. // Soft delete -Tables.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890").execute(); +client.tables().delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Hard delete with recursive -Tables.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890") - .recursive() - .hardDelete() - .execute(); +client.tables().delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890", Map.of("recursive", "true", "hardDelete", "true")); ``` ```bash DELETE /v1/tables/{id} diff --git a/v1.13.x/api-reference/data-assets/tables/followers-votes.mdx b/v1.13.x/api-reference/data-assets/tables/followers-votes.mdx index 3d87e3b44..bd7990e1e 100644 --- a/v1.13.x/api-reference/data-assets/tables/followers-votes.mdx +++ b/v1.13.x/api-reference/data-assets/tables/followers-votes.mdx @@ -51,7 +51,7 @@ Manage followers and votes for table entities. Followers receive notifications a ```python PUT /v1/tables/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Tables configure( @@ -59,39 +59,62 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" user_id = "user-uuid-here" # Add a follower table = Tables.add_followers(table_id, [user_id]) -print(f"Followers: {len(table.followers)}") +print(f"Followers: {len(table.followers.root)}") # Remove a follower table = Tables.remove_followers(table_id, [user_id]) # Add a vote -table = Tables.add_vote(table_id, vote_type="votedUp") +rest.put(f"/tables/{table_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -table = Tables.remove_vote(table_id) +rest.put(f"/tables/{table_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/tables/{id}/followers -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; // Add a follower -Tables.addFollower(tableId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/tables/" + tableId + "/followers", + UUID.fromString(userId) +); // Remove a follower -Tables.removeFollower(tableId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/tables/" + tableId + "/followers/" + userId, + null +); // Add a vote -Tables.vote(tableId, "votedUp"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/tables/" + tableId + "/vote", + Map.of("updatedVoteType", "votedUp") +); // Remove a vote -Tables.vote(tableId, "unVoted"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/tables/" + tableId + "/vote", + Map.of("updatedVoteType", "unVoted") +); ``` ```bash PUT /v1/tables/{id}/followers diff --git a/v1.13.x/api-reference/data-assets/tables/import-export.mdx b/v1.13.x/api-reference/data-assets/tables/import-export.mdx index e915553d3..a97622f8d 100644 --- a/v1.13.x/api-reference/data-assets/tables/import-export.mdx +++ b/v1.13.x/api-reference/data-assets/tables/import-export.mdx @@ -14,7 +14,7 @@ Export table metadata (columns, owners, tags, descriptions) to CSV and import ch `GET /v1/tables/name/{fqn}/export` - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. ## Export Async @@ -80,6 +80,8 @@ result = ( ```java GET /v1/tables/name/{fqn}/export import org.openmetadata.sdk.fluent.Tables; +Tables.setDefaultClient(client); + // Synchronous export String csvData = Tables.exportCsv("snowflake_prod.analytics.public.customers") .execute(); @@ -90,15 +92,14 @@ String jobId = Tables.exportCsv("snowflake_prod.analytics.public.customers") .execute(); // Synchronous import (dry run) -String result = Tables.importCsv("snowflake_prod.analytics.public.customers") +String dryRunResult = Tables.importCsv("snowflake_prod.analytics.public.customers") .withData(csvData) - .dryRun(true) + .dryRun() .execute(); // Apply import String result = Tables.importCsv("snowflake_prod.analytics.public.customers") .withData(csvData) - .dryRun(false) .execute(); ``` diff --git a/v1.13.x/api-reference/data-assets/tables/list.mdx b/v1.13.x/api-reference/data-assets/tables/list.mdx index 117acc2d0..0e200b910 100644 --- a/v1.13.x/api-reference/data-assets/tables/list.mdx +++ b/v1.13.x/api-reference/data-assets/tables/list.mdx @@ -56,25 +56,30 @@ configure( # List with pagination page = Tables.list(limit=50, fields=["columns", "owners", "tags"]) for t in page.entities: - print(f"{t.fullyQualifiedName} ({len(t.columns or [])} columns)") + print(f"{t.fullyQualifiedName.root} ({len(t.columns or [])} columns)") # List all with auto-pagination all_tables = Tables.list_all(batch_size=100) for table in all_tables: - print(f"{table.fullyQualifiedName}") + print(f"{table.fullyQualifiedName.root}") ``` ```java GET /v1/tables -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // Retrieve by ID -Table table = Tables.retrieve(tableId); +Table table = client.tables().get(tableId); // List tables -var result = Tables.list() - .fields("columns", "owners", "tags") - .limit(50) - .execute(); +ListResponse result = client.tables().list( + new ListParams() + .setFields("columns,owners,tags") + .setLimit(50) +); for (Table t : result.getData()) { System.out.println(t.getFullyQualifiedName()); @@ -203,7 +208,7 @@ Returns a paginated list of table objects. By default, only basic fields are inc - Type of table (e.g., `Regular`, `View`, `MaterializedView`). + Type of table, for example `Regular`, `View`, `MaterializedView`. diff --git a/v1.13.x/api-reference/data-assets/tables/observability.mdx b/v1.13.x/api-reference/data-assets/tables/observability.mdx index 6ea18c6db..3c6545813 100644 --- a/v1.13.x/api-reference/data-assets/tables/observability.mdx +++ b/v1.13.x/api-reference/data-assets/tables/observability.mdx @@ -25,69 +25,90 @@ Manage pipeline observability data for a table. This tracks which pipelines prod UUID of the table. - - Name of the pipeline. +The request body is a list. Each item describes one pipeline: + + + Reference to the pipeline. Include its `id` (UUID), `type` (`pipeline`), and `fullyQualifiedName`. - - Fully qualified name of the pipeline. + + Type of the pipeline service, such as `Airflow`. - - Status of the last pipeline run: `Successful`, `Failed`, `Pending`, `Aborted`. + + Schedule of the pipeline, as a cron expression. - + Unix timestamp (milliseconds) of the last pipeline run. - - Unix timestamp (milliseconds) of the next scheduled run. + + Status of the last pipeline run: `Successful`, `Failed`, `Pending`, `Skipped`. + + + + Average run time of the pipeline. ```python GET /v1/tables/{id}/pipelineObservability -from metadata.sdk import configure -from metadata.sdk.entities import Tables +from metadata.sdk import configure, client +from metadata.sdk.entities import Pipelines configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" +rest = client().ometa.client -# Get pipeline observability -observability = Tables.get_pipeline_observability(table_id) -for pipeline in observability: - print(f"{pipeline['pipelineName']}: {pipeline['lastRunStatus']}") +table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add pipeline observability -Tables.add_pipeline_observability(table_id, { - "pipelineName": "customer_etl", - "pipelineFQN": "airflow_prod.customer_etl", - "lastRunStatus": "Successful", - "lastRunTimestamp": 1706745600000, - "nextRunTimestamp": 1706832000000 -}) +pipeline = Pipelines.retrieve_by_name("airflow_prod.customer_etl") +rest.put(f"/tables/{table_id}/pipelineObservability", json=[{ + "pipeline": { + "id": str(pipeline.id.root), + "type": "pipeline", + "fullyQualifiedName": "airflow_prod.customer_etl" + }, + "serviceType": "Airflow", + "scheduleInterval": "0 0 * * *", + "lastRunTime": 1706745600000, + "lastRunStatus": "Successful" +}]) + +# Get pipeline observability +observability = rest.get(f"/tables/{table_id}/pipelineObservability") +for item in observability: + print(f"{item['pipeline']['fullyQualifiedName']}: {item['lastRunStatus']}") ``` ```java GET /v1/tables/{id}/pipelineObservability -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.List; +import org.openmetadata.schema.api.services.CreatePipelineService.PipelineServiceType; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.schema.type.PipelineObservability; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Get pipeline observability -var observability = Tables.getPipelineObservability(tableId); +List observability = client.tables().getPipelineObservability(tableId); // Add pipeline observability -Tables.addPipelineObservability(tableId, Map.of( - "pipelineName", "customer_etl", - "pipelineFQN", "airflow_prod.customer_etl", - "lastRunStatus", "Successful", - "lastRunTimestamp", 1706745600000L, - "nextRunTimestamp", 1706832000000L -)); +Pipeline pipeline = client.pipelines().getByName("airflow_prod.customer_etl"); + +PipelineObservability item = new PipelineObservability() + .withPipeline(pipeline.getEntityReference()) + .withServiceType(PipelineServiceType.Airflow) + .withScheduleInterval("0 0 * * *") + .withLastRunTime(1706745600000L) + .withLastRunStatus(PipelineObservability.LastRunStatus.SUCCESSFUL); + +client.tables().addPipelineObservability(tableId, List.of(item)); ``` ```bash GET /v1/tables/{id}/pipelineObservability @@ -99,25 +120,35 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/pipelineObse curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/pipelineObservability" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ - -d '{ - "pipelineName": "agent_metrics_etl", - "pipelineFQN": "airflow_prod.agent_metrics_etl", - "lastRunStatus": "Successful", - "lastRunTimestamp": 1769982651320, - "nextRunTimestamp": 1770069051320 - }' + -d '[{ + "pipeline": { + "id": "9a1d3c52-6f0b-4c1e-8a57-2b6f4e0d7c11", + "type": "pipeline", + "fullyQualifiedName": "airflow_prod.agent_metrics_etl" + }, + "serviceType": "Airflow", + "scheduleInterval": "0 0 * * *", + "lastRunTime": 1769982651320, + "lastRunStatus": "Successful" + }]' ``` ```json Response (Get Pipeline Observability) -{ - "pipelineName": "customer_etl", - "pipelineFQN": "airflow_prod.customer_etl", - "lastRunStatus": "Successful", - "lastRunTimestamp": 1706745600000, - "nextRunTimestamp": 1706832000000 -} +[ + { + "pipeline": { + "id": "9a1d3c52-6f0b-4c1e-8a57-2b6f4e0d7c11", + "type": "pipeline", + "fullyQualifiedName": "airflow_prod.customer_etl" + }, + "serviceType": "Airflow", + "scheduleInterval": "0 0 * * *", + "lastRunTime": 1706745600000, + "lastRunStatus": "Successful" + } +] ``` @@ -125,30 +156,34 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/pipel ## Returns -**Get** returns pipeline observability data associated with the table. +**Get** returns a list with one item for each pipeline linked to the table. -**Add** returns the updated pipeline observability data. +**Add** returns the updated table. ## Response - - Name of the pipeline. + + Reference to the pipeline, with its `id`, `type`, and `fullyQualifiedName`. - - Fully qualified name of the pipeline. + + Type of the pipeline service. - - Status of the last run. + + Schedule of the pipeline, as a cron expression. - + Unix timestamp of the last run in milliseconds. - - Unix timestamp of the next scheduled run in milliseconds. + + Status of the last run. + + + + Average run time of the pipeline. --- diff --git a/v1.13.x/api-reference/data-assets/tables/profiler.mdx b/v1.13.x/api-reference/data-assets/tables/profiler.mdx index 5a82e3315..360a5861d 100644 --- a/v1.13.x/api-reference/data-assets/tables/profiler.mdx +++ b/v1.13.x/api-reference/data-assets/tables/profiler.mdx @@ -2,7 +2,7 @@ title: Table Profiler description: Manage profiler configuration and retrieve profile data for tables sidebarTitle: Table Profiler -api: GET /v1/tables/{id}/profilerConfig +api: GET /v1/tables/{id}/tableProfilerConfig --- # Table Profiler @@ -11,7 +11,7 @@ Manage the profiler configuration for a table and retrieve profiling results inc ## Get Profiler Config -`GET /v1/tables/{id}/profilerConfig` +`GET /v1/tables/{id}/tableProfilerConfig` UUID of the table. @@ -19,7 +19,7 @@ Manage the profiler configuration for a table and retrieve profiling results inc ## Set Profiler Config -`PUT /v1/tables/{id}/profilerConfig` +`PUT /v1/tables/{id}/tableProfilerConfig` UUID of the table. @@ -61,7 +61,7 @@ Manage the profiler configuration for a table and retrieve profiling results inc ## Delete Profiler Config -`DELETE /v1/tables/{id}/profilerConfig` +`DELETE /v1/tables/{id}/tableProfilerConfig` UUID of the table. @@ -98,8 +98,8 @@ Returns system-level profiling results (DML operations, rows affected). -```python GET /v1/tables/{id}/profilerConfig -from metadata.sdk import configure +```python GET /v1/tables/{id}/tableProfilerConfig +from metadata.sdk import configure, client from metadata.sdk.entities import Tables configure( @@ -107,15 +107,18 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Get profiler config -config = Tables.get_profiler_config(table_id) -sample_config = config.get("profileSampleConfig", {}).get("config", {}) -print(f"Sample: {sample_config.get('profileSample')}%") +table = Tables.retrieve(table_id, fields=["tableProfilerConfig"]) +config = table.tableProfilerConfig +if config and config.profileSampleConfig: + print(f"Sample: {config.profileSampleConfig.config.profileSample}%") # Set profiler config - profile 50% of rows -Tables.set_profiler_config(table_id, { +rest.put(f"/tables/{table_id}/tableProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": {"profileSample": 50, "profileSampleType": "PERCENTAGE"} @@ -125,7 +128,7 @@ Tables.set_profiler_config(table_id, { }) # Set profiler config with specific column metrics -Tables.set_profiler_config(table_id, { +rest.put(f"/tables/{table_id}/tableProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": {"profileSample": 100, "profileSampleType": "PERCENTAGE"} @@ -137,38 +140,50 @@ Tables.set_profiler_config(table_id, { }) # Delete profiler config -Tables.delete_profiler_config(table_id) +rest.delete(f"/tables/{table_id}/tableProfilerConfig") ``` -```java GET /v1/tables/{id}/profilerConfig -import static org.openmetadata.sdk.fluent.Tables.*; +```java GET /v1/tables/{id}/tableProfilerConfig +import java.util.List; +import java.util.Map; +import org.openmetadata.schema.type.ProfileSampleConfig; +import org.openmetadata.schema.type.TableProfilerConfig; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Get profiler config -var config = Tables.getProfilerConfig(tableId); +TableProfilerConfig profilerConfig = client.tables() + .get(tableId, "tableProfilerConfig") + .getTableProfilerConfig(); // Set profiler config -Tables.setProfilerConfig(tableId, Map.of( - "profileSampleConfig", Map.of( - "sampleConfigType", "STATIC", - "config", Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE") - ), - "sampleDataCount", 200, - "excludeColumns", List.of("created_at") -)); +TableProfilerConfig newConfig = new TableProfilerConfig() + .withProfileSampleConfig(new ProfileSampleConfig() + .withSampleConfigType(ProfileSampleConfig.SampleConfigType.STATIC) + .withConfig(Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE"))) + .withSampleDataCount(200) + .withExcludeColumns(List.of("created_at")); +client.tables().updateProfilerConfig(tableId, newConfig); // Delete profiler config -Tables.deleteProfilerConfig(tableId); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/tables/" + tableId + "/tableProfilerConfig", + null, + Void.class +); ``` -```bash GET /v1/tables/{id}/profilerConfig +```bash GET /v1/tables/{id}/tableProfilerConfig # Get profiler config -curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profilerConfig" \ +curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/tableProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Set profiler config -curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profilerConfig" \ +curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/tableProfilerConfig" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -181,7 +196,7 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profi }' # Delete profiler config -curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profilerConfig" \ +curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/tableProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Get table profile @@ -201,12 +216,16 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/systemProfil ```json Response (Profiler Config) { - "profileSampleConfig": { - "sampleConfigType": "STATIC", - "config": {"profileSample": 50, "profileSampleType": "PERCENTAGE"} - }, - "sampleDataCount": 200, - "excludeColumns": ["created_at"] + "id": "455e3d9d-dbbf-455e-b3be-7191daa825f3", + "name": "agent_performance", + "tableProfilerConfig": { + "profileSampleConfig": { + "sampleConfigType": "STATIC", + "config": {"profileSample": 50, "profileSampleType": "PERCENTAGE"} + }, + "sampleDataCount": 200, + "excludeColumns": ["created_at"] + } } ``` @@ -215,11 +234,11 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/systemProfil ## Returns -**Get profiler config** returns the profiler configuration object. +**Get profiler config** returns the table. The configuration is in its `tableProfilerConfig` field. -**Set profiler config** returns the updated profiler configuration. +**Set profiler config** returns the updated table. -**Delete profiler config** returns no content (204). +**Delete profiler config** returns the updated table, without a profiler configuration. **Get table profile** returns table-level metrics (row count, size, etc.). @@ -229,6 +248,8 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/systemProfil ## Response (Profiler Config) +These fields are inside the table's `tableProfilerConfig` field. + How much data is profiled. Contains `sampleConfigType` (`STATIC` or `DYNAMIC`) and a `config` object holding the settings for that type. diff --git a/v1.13.x/api-reference/data-assets/tables/relationships.mdx b/v1.13.x/api-reference/data-assets/tables/relationships.mdx index 41d79793f..f68fc13c9 100644 --- a/v1.13.x/api-reference/data-assets/tables/relationships.mdx +++ b/v1.13.x/api-reference/data-assets/tables/relationships.mdx @@ -20,7 +20,7 @@ Record join information between this table and other tables. - Start date for the join period (ISO 8601 format). + Start date for the join period (ISO 8601 format). The period must fall within the past 30 days, ending today. In the examples, `{start_date}` stands for a date in this range, such as today's date. @@ -40,7 +40,7 @@ Record join information between this table and other tables. - FQN of the joined column (e.g., `snowflake_prod.analytics.public.orders.customer_id`). + FQN of the joined column, for example `snowflake_prod.analytics.public.orders.customer_id`. @@ -62,7 +62,7 @@ Set the data model (dbt or similar) associated with this table. - Type of data model: `DBT`, `LookML`. + Type of data model: `DBT` or `DDL`. @@ -74,7 +74,7 @@ Set the data model (dbt or similar) associated with this table. - Column descriptions and metadata from the data model. + Column descriptions and metadata from the data model. Each column needs a `name` and a `dataType`. ## Get Columns @@ -97,20 +97,23 @@ Retrieve column information with optional pagination. ```python PUT /v1/tables/{id}/joins -from metadata.sdk import configure -from metadata.sdk.entities import Tables +from datetime import date + +from metadata.sdk import configure, client configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add join information -Tables.add_joins(table_id, { - "startDate": "2024-01-01", - "dayCount": 30, +rest.put(f"/tables/{table_id}/joins", json={ + "startDate": date.today().isoformat(), + "dayCount": 1, "columnJoins": [ { "columnName": "id", @@ -125,47 +128,52 @@ Tables.add_joins(table_id, { }) # Set data model -Tables.set_data_model(table_id, { +rest.put(f"/tables/{table_id}/dataModel", json={ "modelType": "DBT", "description": "Customer dimension table built from raw events", "sql": "SELECT id, name, email, created_at FROM raw.customers WHERE active = true", "columns": [ - {"name": "id", "description": "Primary key from source"}, - {"name": "name", "description": "Customer full name"}, - {"name": "email", "description": "Verified email address"}, - {"name": "created_at", "description": "First seen timestamp"} + {"name": "id", "dataType": "INT", "description": "Primary key from source"}, + {"name": "name", "dataType": "VARCHAR", "description": "Customer full name"}, + {"name": "email", "dataType": "VARCHAR", "description": "Verified email address"}, + {"name": "created_at", "dataType": "TIMESTAMP", "description": "First seen timestamp"} ] }) ``` ```java PUT /v1/tables/{id}/joins -import static org.openmetadata.sdk.fluent.Tables.*; +import java.time.LocalDate; +import java.util.List; +import org.openmetadata.schema.type.ColumnJoin; +import org.openmetadata.schema.type.DataModel; +import org.openmetadata.schema.type.JoinedWith; +import org.openmetadata.schema.type.TableJoins; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Add join information -Tables.addJoins(tableId, Map.of( - "startDate", "2024-01-01", - "dayCount", 30, - "columnJoins", List.of( - Map.of( - "columnName", "id", - "joinedWith", List.of( - Map.of( - "fullyQualifiedName", "snowflake_prod.analytics.public.orders.customer_id", - "joinCount", 1542 - ) - ) - ) - ) -)); +TableJoins joins = new TableJoins() + .withStartDate(LocalDate.now().toString()) + .withDayCount(1) + .withColumnJoins(List.of( + new ColumnJoin() + .withColumnName("id") + .withJoinedWith(List.of( + new JoinedWith() + .withFullyQualifiedName("snowflake_prod.analytics.public.orders.customer_id") + .withJoinCount(1542) + )) + )); +client.tables().updateJoins(tableId, joins); // Set data model -Tables.setDataModel(tableId, Map.of( - "modelType", "DBT", - "description", "Customer dimension table built from raw events", - "sql", "SELECT id, name, email, created_at FROM raw.customers WHERE active = true" -)); +DataModel dataModel = new DataModel() + .withModelType(DataModel.ModelType.DBT) + .withDescription("Customer dimension table built from raw events") + .withSql("SELECT id, name, email, created_at FROM raw.customers WHERE active = true"); +client.tables().updateDataModel(tableId, dataModel); ``` ```bash PUT /v1/tables/{id}/joins @@ -174,8 +182,8 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/joins -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ - "startDate": "2024-01-01", - "dayCount": 30, + "startDate": "{start_date}", + "dayCount": 1, "columnJoins": [ { "columnName": "agent_id", @@ -208,8 +216,8 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/columns?limi ```json Response (Add Joins) { - "startDate": "2024-01-01", - "dayCount": 30, + "startDate": "{start_date}", + "dayCount": 1, "columnJoins": [ { "columnName": "agent_id", diff --git a/v1.13.x/api-reference/data-assets/tables/retrieve.mdx b/v1.13.x/api-reference/data-assets/tables/retrieve.mdx index 4ef5e0c6c..0ecb28395 100644 --- a/v1.13.x/api-reference/data-assets/tables/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/tables/retrieve.mdx @@ -28,7 +28,7 @@ Get a single table by its unique ID or fully qualified name. Use `GET /v1/tables/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. @@ -51,7 +51,7 @@ configure( # Get by ID table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890") -print(f"{table.fullyQualifiedName}: {table.description}") +print(f"{table.fullyQualifiedName.root}: {table.name.root}") # Get by ID with fields table = Tables.retrieve( @@ -70,13 +70,15 @@ table = Tables.retrieve_by_name( ``` ```java GET /v1/tables/{id} -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; + +// client is an initialized OpenMetadataClient. // Get by ID -Table table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +Table table = client.tables().get("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Get by fully qualified name -Table table = Tables.retrieveByName("snowflake_prod.analytics.public.customers"); +Table tableByName = client.tables().getByName("snowflake_prod.analytics.public.customers"); ``` ```bash GET /v1/tables/{id} diff --git a/v1.13.x/api-reference/data-assets/tables/sample-data.mdx b/v1.13.x/api-reference/data-assets/tables/sample-data.mdx index a41bc9edd..834f6d795 100644 --- a/v1.13.x/api-reference/data-assets/tables/sample-data.mdx +++ b/v1.13.x/api-reference/data-assets/tables/sample-data.mdx @@ -26,17 +26,7 @@ Manage sample data rows for a table. Sample data provides a preview of the table - Array of column references describing the sample data columns. - - - - Name of the column. - - - - Data type of the column. - - + Array of column names, in the same order as the values in each row. @@ -53,65 +43,68 @@ Manage sample data rows for a table. Sample data provides a preview of the table ```python GET /v1/tables/{id}/sampleData -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Tables +from metadata.generated.schema.entity.data.table import TableData configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" +rest = client().ometa.client -# Get sample data -sample = Tables.get_sample_data(table_id) -for row in sample.get("rows", []): - print(row) +table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add sample data -Tables.add_sample_data(table_id, { - "columns": [ - {"name": "id", "dataType": "INT"}, - {"name": "name", "dataType": "VARCHAR"}, - {"name": "email", "dataType": "VARCHAR"}, - {"name": "created_at", "dataType": "TIMESTAMP"} - ], - "rows": [ +Tables.add_sample_data(table_id, TableData( + columns=["id", "name", "email", "created_at"], + rows=[ [1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"], [2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"], [3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z"] ] -}) +)) + +# Get sample data +table = Tables.get_sample_data(table_id) +for row in table.sampleData.rows: + print(row) # Delete sample data -Tables.delete_sample_data(table_id) +rest.delete(f"/tables/{table_id}/sampleData") ``` ```java GET /v1/tables/{id}/sampleData -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.TableData; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Get sample data -var sample = Tables.getSampleData(tableId); +Table sample = client.tables().getSampleData(tableId); // Add sample data -Tables.addSampleData(tableId, Map.of( - "columns", List.of( - Map.of("name", "id", "dataType", "INT"), - Map.of("name", "name", "dataType", "VARCHAR"), - Map.of("name", "email", "dataType", "VARCHAR"), - Map.of("name", "created_at", "dataType", "TIMESTAMP") - ), - "rows", List.of( - List.of(1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"), - List.of(2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"), - List.of(3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z") - ) -)); +TableData sampleData = new TableData() + .withColumns(List.of("id", "name", "email", "created_at")) + .withRows(List.of( + List.of(1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"), + List.of(2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"), + List.of(3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z") + )); +client.tables().updateSampleData(tableId, sampleData); // Delete sample data -Tables.deleteSampleData(tableId); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/tables/" + tableId + "/sampleData", + null, + Void.class +); ``` ```bash GET /v1/tables/{id}/sampleData @@ -124,10 +117,7 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampl -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ - "columns": [ - {"name": "agent_id", "dataType": "VARCHAR"}, - {"name": "performance_score", "dataType": "DECIMAL"} - ], + "columns": ["agent_id", "performance_score"], "rows": [ ["AGT-001", 92.5], ["AGT-002", 87.3], @@ -144,15 +134,16 @@ curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sa ```json Response (Get Sample Data) { - "columns": [ - {"name": "agent_id", "dataType": "VARCHAR"}, - {"name": "performance_score", "dataType": "DECIMAL"} - ], - "rows": [ - ["AGT-001", 92.5], - ["AGT-002", 87.3], - ["AGT-003", 95.1] - ] + "id": "455e3d9d-dbbf-455e-b3be-7191daa825f3", + "name": "agent_performance", + "sampleData": { + "columns": ["agent_id", "performance_score"], + "rows": [ + ["AGT-001", 92.5], + ["AGT-002", 87.3], + ["AGT-003", 95.1] + ] + } } ``` @@ -161,26 +152,16 @@ curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sa ## Returns -**Get** returns the sample data object with columns and rows arrays. +**Get** returns the table. The sample data is in its `sampleData` field, with `columns` and `rows` arrays. -**Add** returns the updated sample data object. +**Add** returns the updated table. -**Delete** returns no content (204). +**Delete** returns the updated table, without sample data. ## Response - Array of column definitions for the sample data. - - - - Column name. - - - - Data type of the column. - - + Array of column names for the sample data. This field is inside `sampleData`. diff --git a/v1.13.x/api-reference/data-assets/tables/update.mdx b/v1.13.x/api-reference/data-assets/tables/update.mdx index a11af994f..10aa7ed85 100644 --- a/v1.13.x/api-reference/data-assets/tables/update.mdx +++ b/v1.13.x/api-reference/data-assets/tables/update.mdx @@ -20,7 +20,7 @@ Update a table's properties using JSON Merge Patch. You can update by ID or by f Use `PATCH /v1/tables/name/{fqn}` to update by fully qualified name. - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,11 +58,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -75,8 +75,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. Updated column definitions. Use this to update column descriptions, tags, or add new columns. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -98,16 +98,18 @@ table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890") table.description = "Updated customer master data table with PII fields" updated = Tables.update(table) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/tables/{id} -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -Table table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +Table table = client.tables().get("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); table.setDescription("Updated customer master data table with PII fields"); -Table updated = Tables.update(table); +Table updated = client.tables().update("a1b2c3d4-e5f6-7890-abcd-ef1234567890", table); ``` ```bash PATCH /v1/tables/{id} diff --git a/v1.13.x/api-reference/data-assets/tables/versions.mdx b/v1.13.x/api-reference/data-assets/tables/versions.mdx index e842e5181..69de38be5 100644 --- a/v1.13.x/api-reference/data-assets/tables/versions.mdx +++ b/v1.13.x/api-reference/data-assets/tables/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/tables/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/tables/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Tables @@ -40,26 +42,30 @@ configure( # List all versions versions = Tables.get_versions("a1b2c3d4-e5f6-7890-abcd-ef1234567890") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version table_v1 = Tables.get_specific_version( "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "0.1" ) -print(f"Original description: {table_v1.description}") +print(f"Original description: {table_v1.description.root if table_v1.description else None}") ``` ```java GET /v1/tables/{id}/versions -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = Tables.getVersions("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +EntityHistory versions = client.tables().getVersionList("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Get a specific version -Table v1 = Tables.getSpecificVersion( +Table v1 = client.tables().getVersion( "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "0.1" + 0.1 ); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-assets/topics/create.mdx b/v1.13.x/api-reference/data-assets/topics/create.mdx index 46dc41b30..42f31b955 100644 --- a/v1.13.x/api-reference/data-assets/topics/create.mdx +++ b/v1.13.x/api-reference/data-assets/topics/create.mdx @@ -16,7 +16,7 @@ Create a new topic within a messaging service. - Fully qualified name of the parent MessagingService (e.g., `sample_kafka`). + Fully qualified name of the parent MessagingService, for example `sample_kafka`. @@ -24,7 +24,7 @@ Create a new topic within a messaging service. - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`, `Other`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`, `Other`. @@ -38,7 +38,7 @@ Create a new topic within a messaging service. - Array of cleanup policies for the topic (e.g., `delete`, `compact`). + Array of cleanup policies for the topic, for example `delete`, `compact`. @@ -70,7 +70,7 @@ Create a new topic within a messaging service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -79,8 +79,8 @@ Create a new topic within a messaging service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -92,11 +92,11 @@ Create a new topic within a messaging service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -107,13 +107,22 @@ Create a new topic within a messaging service. ```python POST /v1/topics -from metadata.sdk import configure -from metadata.sdk.entities import Topics +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.generated.schema.api.data.createTopic import CreateTopicRequest -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) request = CreateTopicRequest( @@ -132,23 +141,28 @@ request = CreateTopicRequest( retentionSize=-1 ) -topic = Topics.create(request) -print(f"Created: {topic.fullyQualifiedName}") +topic = metadata.create_or_update(request) +print(f"Created: {topic.fullyQualifiedName.root}") ``` ```java POST /v1/topics -import static org.openmetadata.sdk.fluent.Topics.*; - -// Create using builder pattern -var topic = Topics.builder() - .name("address_book") - .displayName("Address Book") - .service("sample_kafka") - .description("All Protobuf record related events gets captured in this topic") - .partitions(1) - .cleanupPolicies(List.of("delete")) - .replicationFactor(1) - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateTopic; +import org.openmetadata.schema.entity.data.Topic; +import org.openmetadata.schema.type.topic.CleanupPolicy; + +// client is an initialized OpenMetadataClient. + +CreateTopic request = new CreateTopic() + .withName("address_book") + .withDisplayName("Address Book") + .withService("sample_kafka") + .withDescription("All Protobuf record related events gets captured in this topic") + .withPartitions(1) + .withCleanupPolicies(List.of(CleanupPolicy.DELETE)) + .withReplicationFactor(1); + +Topic topic = client.topics().create(request); ``` ```bash POST /v1/topics @@ -279,7 +293,7 @@ Returns the created topic object with all specified properties and system-genera - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`. @@ -313,7 +327,7 @@ Returns the created topic object with all specified properties and system-genera - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. @@ -325,7 +339,7 @@ Returns the created topic object with all specified properties and system-genera - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -347,11 +361,11 @@ Returns the created topic object with all specified properties and system-genera - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v1.13.x/api-reference/data-assets/topics/delete.mdx b/v1.13.x/api-reference/data-assets/topics/delete.mdx index c257242e7..ec7656a55 100644 --- a/v1.13.x/api-reference/data-assets/topics/delete.mdx +++ b/v1.13.x/api-reference/data-assets/topics/delete.mdx @@ -28,7 +28,7 @@ Delete a topic by ID or fully qualified name. Supports soft delete (default), ha Use `DELETE /v1/topics/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the topic (e.g., `sample_kafka.address_book`). + Fully qualified name of the topic, for example `sample_kafka.address_book`. @@ -49,53 +49,64 @@ Use `PUT /v1/topics/restore` to restore a soft-deleted topic. ```python DELETE /v1/topics/{id} -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Soft delete by ID -Topics.delete("0a021819-982e-4ee4-a5a2-4af30eaa3016") +metadata.delete(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") # Hard delete -Topics.delete( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", +metadata.delete( + entity=Topic, + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", hard_delete=True ) # Delete by name -Topics.delete_by_name("sample_kafka.address_book") +topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book") +metadata.delete(entity=Topic, entity_id=topic.id) # Delete by name with options -Topics.delete_by_name( - "sample_kafka.address_book", - hard_delete=True -) +topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book") +metadata.delete(entity=Topic, entity_id=topic.id, hard_delete=True) # Restore a soft-deleted topic -Topics.restore("0a021819-982e-4ee4-a5a2-4af30eaa3016") +metadata.restore(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") ``` ```java DELETE /v1/topics/{id} -import static org.openmetadata.sdk.fluent.Topics.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.Topic; + +// client is an initialized OpenMetadataClient. // Soft delete -Topics.delete("0a021819-982e-4ee4-a5a2-4af30eaa3016").execute(); +client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016"); // Hard delete -Topics.delete("0a021819-982e-4ee4-a5a2-4af30eaa3016") - .hardDelete() - .execute(); +client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016", Map.of("hardDelete", "true")); -// Delete by name -Topics.deleteByName("sample_kafka.address_book") - .execute(); +// Delete by name (look up the ID first) +Topic topic = client.topics().getByName("sample_kafka.address_book"); +client.topics().delete(topic.getId()); // Restore -Topics.restore("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +client.topics().restore("0a021819-982e-4ee4-a5a2-4af30eaa3016"); ``` ```bash DELETE /v1/topics/{id} diff --git a/v1.13.x/api-reference/data-assets/topics/followers-votes.mdx b/v1.13.x/api-reference/data-assets/topics/followers-votes.mdx index b9bec718f..331d96932 100644 --- a/v1.13.x/api-reference/data-assets/topics/followers-votes.mdx +++ b/v1.13.x/api-reference/data-assets/topics/followers-votes.mdx @@ -51,47 +51,66 @@ Manage followers and votes for topic entities. ```python PUT /v1/topics/{id}/followers -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) topic_id = "0a021819-982e-4ee4-a5a2-4af30eaa3016" user_id = "user-uuid-here" # Add a follower -topic = Topics.add_followers(topic_id, [user_id]) -print(f"Followers: {len(topic.followers)}") +metadata.client.put(f"/topics/{topic_id}/followers", json=user_id) +topic = metadata.get_by_id(entity=Topic, entity_id=topic_id, fields=["followers"]) +print(f"Followers: {len(topic.followers.root)}") # Remove a follower -topic = Topics.remove_followers(topic_id, [user_id]) +metadata.client.delete(f"/topics/{topic_id}/followers/{user_id}") # Add a vote -topic = Topics.add_vote(topic_id, vote_type="votedUp") +metadata.client.put(f"/topics/{topic_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -topic = Topics.remove_vote(topic_id) +metadata.client.put(f"/topics/{topic_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/topics/{id}/followers -import static org.openmetadata.sdk.fluent.Topics.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String topicId = "0a021819-982e-4ee4-a5a2-4af30eaa3016"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -Topics.addFollower(topicId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/topics/" + topicId + "/followers", userId); // Remove a follower -Topics.removeFollower(topicId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/topics/" + topicId + "/followers/" + userId, null); // Add a vote -Topics.vote(topicId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/topics/" + topicId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -Topics.vote(topicId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/topics/" + topicId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/topics/{id}/followers diff --git a/v1.13.x/api-reference/data-assets/topics/list.mdx b/v1.13.x/api-reference/data-assets/topics/list.mdx index d50439b00..e45df3cc7 100644 --- a/v1.13.x/api-reference/data-assets/topics/list.mdx +++ b/v1.13.x/api-reference/data-assets/topics/list.mdx @@ -37,59 +37,73 @@ List all topics with optional filtering and pagination. ```python GET /v1/topics -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List first page -topics = Topics.list(limit=50) -for t in topics.data: - print(f"{t.fullyQualifiedName}") +topics = metadata.list_entities(entity=Topic, limit=50) +for topic in topics.entities: + print(f"{topic.fullyQualifiedName.root}") # List all with auto-pagination -for t in Topics.list_all(): - print(f"{t.fullyQualifiedName}") +for topic in metadata.list_all_entities(entity=Topic): + print(f"{topic.fullyQualifiedName.root}") # Filter by service -topics = Topics.list( - service="sample_kafka", - fields=["owners", "tags", "domain"], +topics = metadata.list_entities( + entity=Topic, + fields=["owners", "tags", "domains"], + params={"service": "sample_kafka"}, limit=50 ) -for t in topics.data: - print(f"{t.fullyQualifiedName}") - if t.owners: - print(f" Owners: {[o.name for o in t.owners]}") - if t.tags: - print(f" Tags: {[t.tagFQN for t in t.tags]}") +for topic in topics.entities: + print(f"{topic.fullyQualifiedName.root}") + if topic.owners: + print(f" Owners: {[o.name for o in topic.owners.root]}") + if topic.tags: + print(f" Tags: {[tag.tagFQN.root for tag in topic.tags]}") ``` ```java GET /v1/topics -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = Topics.list() - .limit(50) - .execute(); +ListResponse firstPage = client.topics().list(new ListParams().setLimit(50)); -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +for (Topic item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = Topics.list() - .service("sample_kafka") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +ListResponse filtered = client.topics().list( + new ListParams() + .setService("sample_kafka") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (Topic item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -193,7 +207,7 @@ Returns a paginated list of topic objects. By default, only basic fields are inc - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v1.13.x/api-reference/data-assets/topics/retrieve.mdx b/v1.13.x/api-reference/data-assets/topics/retrieve.mdx index 8b5b9f6ba..f12f32e8d 100644 --- a/v1.13.x/api-reference/data-assets/topics/retrieve.mdx +++ b/v1.13.x/api-reference/data-assets/topics/retrieve.mdx @@ -16,7 +16,7 @@ Get a single topic by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single topic by its unique ID or fully qualified name. Use `GET /v1/topics/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the topic (e.g., `sample_kafka.address_book`). + Fully qualified name of the topic, for example `sample_kafka.address_book`. @@ -41,55 +41,67 @@ Use `GET /v1/topics/name/{fqn}` to retrieve by fully qualified name. ```python GET /v1/topics/{id} -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Get by ID -topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016") -print(f"{topic.fullyQualifiedName}: {topic.description}") +topic = metadata.get_by_id(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") +print(f"{topic.fullyQualifiedName.root}: {topic.description.root}") # Get by ID with fields -topic = Topics.retrieve( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", +topic = metadata.get_by_id( + entity=Topic, + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", fields=["owners", "tags", "messageSchema"] ) # Get by fully qualified name -topic = Topics.retrieve_by_name("sample_kafka.address_book") +topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book") # Get by name with fields -topic = Topics.retrieve_by_name( - "sample_kafka.address_book", - fields=["owners", "tags", "domain"] +topic = metadata.get_by_name( + entity=Topic, + fqn="sample_kafka.address_book", + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/topics/{id} -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; + +// client is an initialized OpenMetadataClient. // Get by ID -var topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +Topic topic = client.topics().get("0a021819-982e-4ee4-a5a2-4af30eaa3016"); // Get by ID with fields -var topic = Topics.retrieve( +Topic topicWithFields = client.topics().get( "0a021819-982e-4ee4-a5a2-4af30eaa3016", "owners,tags,messageSchema" ); // Get by fully qualified name -var topic = Topics.retrieveByName( - "sample_kafka.address_book" -); +Topic topicByName = client.topics().getByName("sample_kafka.address_book"); // Get by name with fields -var topic = Topics.retrieveByName( +Topic topicByNameWithFields = client.topics().getByName( "sample_kafka.address_book", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -219,7 +231,7 @@ Returns a topic object with all requested fields populated. - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`. @@ -233,7 +245,7 @@ Returns a topic object with all requested fields populated. - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v1.13.x/api-reference/data-assets/topics/update.mdx b/v1.13.x/api-reference/data-assets/topics/update.mdx index 2ef93788f..23e3ae18d 100644 --- a/v1.13.x/api-reference/data-assets/topics/update.mdx +++ b/v1.13.x/api-reference/data-assets/topics/update.mdx @@ -20,7 +20,7 @@ Update a topic's properties using JSON Merge Patch. You can update by ID or by f Use `PATCH /v1/topics/name/{fqn}` to update by fully qualified name. - Fully qualified name of the topic (e.g., `sample_kafka.address_book`). + Fully qualified name of the topic, for example `sample_kafka.address_book`. ## Body Parameters @@ -40,7 +40,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`, `Other`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`, `Other`. @@ -58,7 +58,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -72,17 +72,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -91,33 +91,47 @@ Send a JSON object with the fields to update. Only provided fields are changed. ```python PATCH /v1/topics/{id} -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic +from metadata.generated.schema.type.schema import SchemaType, Topic as TopicSchema + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Retrieve, modify, and update -topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016") -topic.description = "Updated: All Protobuf record events captured with enhanced schema" -topic.messageSchema = { - "schemaType": "Protobuf", - "schemaText": "syntax = \"proto3\";\npackage tutorial;\nmessage Person { ... }" -} -updated = Topics.update(topic) +topic = metadata.get_by_id(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") +modified = topic.model_copy(deep=True) +modified.description = "Updated: All Protobuf record events captured with enhanced schema" +modified.messageSchema = TopicSchema( + schemaType=SchemaType.Protobuf, + schemaText="syntax = \"proto3\";\npackage tutorial;\nmessage Person { ... }" +) +updated = metadata.patch(entity=Topic, source=topic, destination=modified) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/topics/{id} -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +Topic topic = client.topics().get("0a021819-982e-4ee4-a5a2-4af30eaa3016"); topic.setDescription("Updated: All Protobuf record events captured with enhanced schema"); -var updated = Topics.update(topic); +Topic updated = client.topics().update(topic.getId(), topic); ``` ```bash PATCH /v1/topics/{id} diff --git a/v1.13.x/api-reference/data-assets/topics/versions.mdx b/v1.13.x/api-reference/data-assets/topics/versions.mdx index c2fdf49fd..ad2bb1382 100644 --- a/v1.13.x/api-reference/data-assets/topics/versions.mdx +++ b/v1.13.x/api-reference/data-assets/topics/versions.mdx @@ -24,47 +24,62 @@ Use `GET /v1/topics/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/topics/{id}/versions -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List all versions -versions = Topics.get_versions("0a021819-982e-4ee4-a5a2-4af30eaa3016") -for v in versions: - print(f"Version {v.version}: {v.description}") +history = metadata.list_versions( + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", + entity=Topic +) +for v in history.versions: + topic_version = Topic.model_validate_json(v) + print(f"Version {topic_version.version.root}: {topic_version.description.root}") # Get a specific version -topic_v1 = Topics.get_specific_version( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", - "0.1" +topic_v1 = metadata.get_entity_version( + entity=Topic, + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", + version="0.1" ) -print(f"Original description: {topic_v1.description}") +print(f"Original description: {topic_v1.description.root}") ``` ```java GET /v1/topics/{id}/versions -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Topics.getVersions("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +EntityHistory history = client.topics().getVersionList("0a021819-982e-4ee4-a5a2-4af30eaa3016"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Topics.getSpecificVersion( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", - 0.1 -); +Topic v1 = client.topics().getVersion("0a021819-982e-4ee4-a5a2-4af30eaa3016", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/data-contracts/create.mdx b/v1.13.x/api-reference/data-contracts/create.mdx index a94d6bbba..675934a9c 100644 --- a/v1.13.x/api-reference/data-contracts/create.mdx +++ b/v1.13.x/api-reference/data-contracts/create.mdx @@ -38,7 +38,7 @@ Create a new data contract and attach it to a data asset. Only the `name` and `e - Contract status: `Draft`, `Active`, or `Deprecated`. + Contract status: `Draft`, `In Review`, `Approved`, `Rejected`, `Deprecated`, or `Archived`. @@ -50,7 +50,7 @@ Create a new data contract and attach it to a data asset. Only the `name` and `e - Data type (e.g., `INT`, `VARCHAR`, `TIMESTAMP`). + Data type, for example `INT`, `VARCHAR`, `TIMESTAMP`. @@ -64,15 +64,31 @@ Create a new data contract and attach it to a data asset. Only the `name` and `e - Semantics rules defining business expectations. + Semantics rules evaluated against the entity's metadata when the contract is validated. - Rule name (e.g., `hasOwner`, `hasDescription`, `hasDomain`, `hasTags`). + Rule name. - - Rule arguments (varies by rule type). + + Rule description. Reported as the failure reason when the rule fails. + + + + [JSON Logic](https://jsonlogic.com/) expression. The rule passes when it returns `true`. + + + + Whether the rule is evaluated. + + + + Apply the rule only to this entity type. + + + + Entity types the rule skips. @@ -92,19 +108,31 @@ Create a new data contract and attach it to a data asset. Only the `name` and `e - Service level agreement expectations. + Service level agreement expectations. Stored and shown on the contract. - - Expected refresh frequency in ISO 8601 duration (e.g., `PT1H`, `P1D`). + + `interval` (integer) and `unit`: `hour`, `day`, `week`, `month`, or `year`. + + + + `value` (integer) and `unit`: `minute`, `hour`, or `day`. + + + + Time of day the data should be available, for example `09:00`. - - Maximum acceptable latency in milliseconds. + + Timezone for `availabilityTime`, in the form `GMT+05:30 (Asia/Kolkata)`. - - Target availability percentage (0-100). + + `period` (integer) and `unit`: `day`, `week`, `month`, or `year`. + + + + Column that holds the data's refresh time. @@ -122,7 +150,7 @@ Create a new data contract and attach it to a data asset. Only the `name` and `e - Required classification tags (e.g., `PII.Sensitive`). + Required classification tags, for example `PII.Sensitive`. @@ -147,61 +175,60 @@ Create a new data contract and attach it to a data asset. Only the `name` and `e ```python POST /v1/dataContracts from metadata.sdk import configure from metadata.sdk.entities import DataContracts +from metadata.generated.schema.api.data.createDataContract import ( + CreateDataContractRequest, +) configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -# Create a basic data contract for a table -contract = DataContracts.create( - name="sales-orders-contract", - entity={ - "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "type": "table" - }, - description="Data contract for the sales orders table", - entityStatus="Active", - schema=[ +request = CreateDataContractRequest.model_validate({ + "name": "sales-orders-contract", + "entity": {"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "type": "table"}, + "description": "Data contract for the sales orders table", + "entityStatus": "Approved", + "schema": [ {"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"}, - {"name": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"}, {"name": "order_date", "dataType": "TIMESTAMP", "constraint": "NOT_NULL"}, - {"name": "total_amount", "dataType": "DECIMAL"} ], - semantics=[ - {"name": "hasOwner"}, - {"name": "hasDescription"}, - {"name": "hasTags"} + "semantics": [ + { + "name": "Owners is set", + "description": "The table must have an owner.", + "rule": '{"and":[{"some":[{"var":"owners"},{"!=":[{"var":"fullyQualifiedName"},null]}]}]}', + "enabled": True, + } ], - sla={ - "refreshFrequency": "PT1H", - "availability": 99.9 - } -) -print(f"Created contract: {contract.fullyQualifiedName}") + "sla": {"refreshFrequency": {"interval": 1, "unit": "day"}}, +}) +contract = DataContracts.create(request) +print(f"Created contract: {contract.fullyQualifiedName.root}") ``` ```java POST /v1/dataContracts import static org.openmetadata.sdk.fluent.DataContracts.*; -// Create a data contract with fluent API DataContract contract = create() .name("sales-orders-contract") .forEntity(new EntityReference() .withId(tableId) .withType("table")) .withDescription("Data contract for the sales orders table") - .withStatus(EntityStatus.ACTIVE) + .withStatus(EntityStatus.APPROVED) .withSchema(List.of( new Column().withName("order_id").withDataType(ColumnDataType.INT), - new Column().withName("customer_id").withDataType(ColumnDataType.INT), new Column().withName("order_date").withDataType(ColumnDataType.TIMESTAMP) )) - .withSemanticRule(new SemanticsRule().withName("hasOwner")) - .withSemanticRule(new SemanticsRule().withName("hasDescription")) + .withSemanticRule(new SemanticsRule() + .withName("Owners is set") + .withDescription("The table must have an owner.") + .withRule("{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}")) .withSla(new ContractSLA() - .withRefreshFrequency("PT1H") - .withAvailability(99.9)) + .withRefreshFrequency(new RefreshFrequency() + .withInterval(1) + .withUnit(RefreshFrequency.Unit.DAY))) .execute(); ``` @@ -216,7 +243,7 @@ curl -X POST "{base_url}/api/v1/dataContracts" \ "type": "table" }, "description": "Data contract for the sales orders table", - "entityStatus": "Active", + "entityStatus": "Approved", "schema": [ {"name": "order_id", "dataType": "INT", "constraint": "PRIMARY_KEY"}, {"name": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"}, @@ -224,13 +251,15 @@ curl -X POST "{base_url}/api/v1/dataContracts" \ {"name": "total_amount", "dataType": "DECIMAL"} ], "semantics": [ - {"name": "hasOwner"}, - {"name": "hasDescription"}, - {"name": "hasTags"} + { + "name": "Owners is set", + "description": "The table must have an owner.", + "rule": "{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}", + "enabled": true + } ], "sla": { - "refreshFrequency": "PT1H", - "availability": 99.9 + "refreshFrequency": {"interval": 1, "unit": "day"} } }' ``` @@ -241,10 +270,10 @@ curl -X POST "{base_url}/api/v1/dataContracts" \ { "id": "f7a1b2c3-d4e5-6789-0abc-def123456789", "name": "sales-orders-contract", - "fullyQualifiedName": "sales-orders-contract", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "displayName": "sales-orders-contract", "description": "Data contract for the sales orders table", - "entityStatus": "Active", + "entityStatus": "Approved", "entity": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "type": "table", @@ -258,13 +287,15 @@ curl -X POST "{base_url}/api/v1/dataContracts" \ {"name": "total_amount", "dataType": "DECIMAL"} ], "semantics": [ - {"name": "hasOwner"}, - {"name": "hasDescription"}, - {"name": "hasTags"} + { + "name": "Owners is set", + "description": "The table must have an owner.", + "rule": "{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}", + "enabled": true + } ], "sla": { - "refreshFrequency": "PT1H", - "availability": 99.9 + "refreshFrequency": {"interval": 1, "unit": "day"} }, "version": 0.1, "updatedAt": 1769982800000, diff --git a/v1.13.x/api-reference/data-contracts/delete.mdx b/v1.13.x/api-reference/data-contracts/delete.mdx index e58a26fbe..5b5f8af11 100644 --- a/v1.13.x/api-reference/data-contracts/delete.mdx +++ b/v1.13.x/api-reference/data-contracts/delete.mdx @@ -67,7 +67,7 @@ curl -X DELETE "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def12345 -H "Authorization: Bearer {access_token}" # Delete by FQN -curl -X DELETE "{base_url}/api/v1/dataContracts/name/sales-orders-contract?hardDelete=true" \ +curl -X DELETE "{base_url}/api/v1/dataContracts/name/sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract?hardDelete=true" \ -H "Authorization: Bearer {access_token}" # Restore soft-deleted contract diff --git a/v1.13.x/api-reference/data-contracts/list.mdx b/v1.13.x/api-reference/data-contracts/list.mdx index 27a50743c..af34ed326 100644 --- a/v1.13.x/api-reference/data-contracts/list.mdx +++ b/v1.13.x/api-reference/data-contracts/list.mdx @@ -32,7 +32,7 @@ Retrieve a paginated list of data contracts, optionally filtered by status or en - Filter by contract status: `Draft`, `Active`, or `Deprecated`. + Filter by contract status: `Draft`, `In Review`, `Approved`, `Rejected`, `Deprecated`, or `Archived`. @@ -49,13 +49,13 @@ configure( jwt_token="your-jwt-token" ) -# List all active contracts -contracts = DataContracts.list(params={"status": "Active"}) -for c in contracts.data: - print(f"{c.fullyQualifiedName} ({c.entityStatus})") +# List approved contracts +contracts = DataContracts.list(filters={"status": "Approved"}) +for c in contracts.entities: + print(f"{c.fullyQualifiedName.root} ({c.entityStatus})") # List contracts for a specific entity -contracts = DataContracts.list(params={ +contracts = DataContracts.list(filters={ "entity": "a1b2c3d4-e5f6-7890-abcd-ef1234567890" }) ``` @@ -74,8 +74,8 @@ list().limit(20).fetch().forEach(contract -> { curl "{base_url}/api/v1/dataContracts?limit=10" \ -H "Authorization: Bearer {access_token}" -# List active contracts -curl "{base_url}/api/v1/dataContracts?status=Active&fields=owners" \ +# List approved contracts +curl "{base_url}/api/v1/dataContracts?status=Approved&fields=owners" \ -H "Authorization: Bearer {access_token}" # List contracts for a specific entity @@ -91,8 +91,8 @@ curl "{base_url}/api/v1/dataContracts?entity=a1b2c3d4-e5f6-7890-abcd-ef123456789 { "id": "f7a1b2c3-d4e5-6789-0abc-def123456789", "name": "sales-orders-contract", - "fullyQualifiedName": "sales-orders-contract", - "entityStatus": "Active", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", + "entityStatus": "Approved", "entity": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "type": "table", diff --git a/v1.13.x/api-reference/data-contracts/odcs.mdx b/v1.13.x/api-reference/data-contracts/odcs.mdx index 72c72783d..c52a9e5e6 100644 --- a/v1.13.x/api-reference/data-contracts/odcs.mdx +++ b/v1.13.x/api-reference/data-contracts/odcs.mdx @@ -59,16 +59,26 @@ yaml_str = DataContracts.export_odcs(contract_id).as_yaml().execute() print(yaml_str) # Export by FQN -odcs = DataContracts.export_odcs_by_name("sales-orders-contract").execute() +odcs = DataContracts.export_odcs_by_name("sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract").execute() ``` ```java Export ODCS -// Export using the REST client +import java.util.UUID; + +// client is an initialized OpenMetadataClient. +var contractId = UUID.fromString("f7a1b2c3-d4e5-6789-0abc-def123456789"); + +// Export as an ODCS object var odcs = client.dataContracts().exportToODCS(contractId); System.out.println("ODCS version: " + odcs.getApiVersion()); +System.out.println("Status: " + odcs.getStatus()); // Export as YAML String yaml = client.dataContracts().exportToODCSYaml(contractId); + +// Export by fully qualified name +var byName = client.dataContracts().exportToODCSByFqn( + "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract"); ``` ```bash Export ODCS @@ -82,7 +92,7 @@ curl "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/odcs/ -H "Accept: application/yaml" # Export by FQN -curl "{base_url}/api/v1/dataContracts/name/sales-orders-contract/odcs" \ +curl "{base_url}/api/v1/dataContracts/name/sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract/odcs" \ -H "Authorization: Bearer {access_token}" ``` @@ -173,7 +183,7 @@ curl "{base_url}/api/v1/dataContracts/name/sales-orders-contract/odcs" \ - Type of the entity (e.g., `table`, `topic`, `apiEndpoint`). + Type of the entity, for example `table`, `topic`, `apiEndpoint`. @@ -207,15 +217,43 @@ contract = (DataContracts.import_odcs(table_id, "table") ``` ```java Import ODCS -// Import from ODCS JSON -var contract = client.dataContracts().importFromODCS( - entityId, "table", odcsContract -); - -// Import from YAML -var contract = client.dataContracts().importFromODCSYaml( - entityId, "table", yamlContent -); +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.UUID; +import org.openmetadata.schema.entity.data.DataContract; +import org.openmetadata.sdk.network.HttpMethod; +import org.openmetadata.sdk.network.RequestOptions; + +// client is an initialized OpenMetadataClient. +var entityId = UUID.fromString("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +String yamlContent = Files.readString(Path.of("contract.yaml")); + +// Import from an ODCS object (creates a new contract). +// odcsContract is an ODCSDataContract, for example one returned by exportToODCS. +var imported = client.dataContracts().importFromODCS(odcsContract, entityId, "table"); + +// Import from YAML (creates a new contract) +var importedFromYaml = client.dataContracts().importFromODCSYaml( + yamlContent, entityId, "table"); + +// Update an existing contract from YAML with smart merge +var merged = client.dataContracts().createOrUpdateFromODCSYaml( + yamlContent, entityId, "table"); + +// Replace an existing contract from YAML +var replaced = client.dataContracts().createOrUpdateFromODCSYaml( + yamlContent, entityId, "table", "replace"); + +// Import from YAML, keeping quality rules without creating test cases. +// The SDK method has no createTestCases option, so call the endpoint directly. +var options = RequestOptions.builder() + .queryParam("entityId", entityId.toString()) + .queryParam("entityType", "table") + .queryParam("createTestCases", "false") + .header("Content-Type", "application/yaml") + .build(); +var withoutTestCases = client.getHttpClient().execute( + HttpMethod.POST, "/v1/dataContracts/odcs/yaml", yamlContent, DataContract.class, options); ``` ```bash Import ODCS @@ -296,6 +334,35 @@ curl -X POST "{base_url}/api/v1/dataContracts/odcs/validate/yaml?entityId=a1b2c3 --data-binary @contract.yaml ``` +```java Validate YAML +import com.fasterxml.jackson.databind.ObjectMapper; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; +import org.openmetadata.sdk.network.RequestOptions; + +// client is an initialized OpenMetadataClient. +var entityId = UUID.fromString("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +String yamlContent = Files.readString(Path.of("contract.yaml")); + +var validation = client.dataContracts().validateODCSYaml(yamlContent, entityId, "table"); +System.out.println("Valid: " + validation.getValid()); + +// The SDK model has no createTestCases option or import report, +// so call the endpoint directly to read the report. +var options = RequestOptions.builder() + .queryParam("entityId", entityId.toString()) + .queryParam("entityType", "table") + .queryParam("createTestCases", "true") + .header("Content-Type", "application/yaml") + .build(); +String response = client.getHttpClient().executeForString( + HttpMethod.POST, "/v1/dataContracts/odcs/validate/yaml", yamlContent, options); +var report = new ObjectMapper().readTree(response).path("odcsImportReport"); +System.out.println("Can import: " + report.path("canImport").asBoolean()); +``` + ```json Response { "passed": 3, diff --git a/v1.13.x/api-reference/data-contracts/retrieve.mdx b/v1.13.x/api-reference/data-contracts/retrieve.mdx index d7794928a..03f365513 100644 --- a/v1.13.x/api-reference/data-contracts/retrieve.mdx +++ b/v1.13.x/api-reference/data-contracts/retrieve.mdx @@ -36,7 +36,7 @@ Use `GET /v1/dataContracts/entity` to get the effective contract for an entity, - Type of the entity (e.g., `table`, `topic`, `dashboard`). + Type of the entity, for example `table`, `topic`, `dashboard`. @@ -54,17 +54,17 @@ configure( ) # Get by ID -contract = DataContracts.get("f7a1b2c3-d4e5-6789-0abc-def123456789") -print(f"{contract.name}: {contract.entityStatus}") +contract = DataContracts.retrieve("f7a1b2c3-d4e5-6789-0abc-def123456789") +print(f"{contract.name.root}: {contract.entityStatus}") # Get by FQN -contract = DataContracts.get_by_name("sales-orders-contract") +contract = DataContracts.retrieve_by_name("sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract") # Get effective contract for an entity (includes inherited properties) -contract = DataContracts.get(params={ - "entityId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "entityType": "table" -}) +contract = DataContracts.get_by_entity( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + "table" +) ``` ```java GET /v1/dataContracts/{id} @@ -77,7 +77,7 @@ FluentDataContract contract = find(contractId) System.out.println(contract.getFqn()); // Get by FQN -FluentDataContract contract = findByName("sales-orders-contract") +FluentDataContract contract = findByName("sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract") .includeAll() .fetch(); @@ -92,7 +92,7 @@ curl "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789?field -H "Authorization: Bearer {access_token}" # Get by FQN -curl "{base_url}/api/v1/dataContracts/name/sales-orders-contract" \ +curl "{base_url}/api/v1/dataContracts/name/sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract" \ -H "Authorization: Bearer {access_token}" # Get effective contract for an entity (includes inherited) @@ -106,9 +106,9 @@ curl "{base_url}/api/v1/dataContracts/entity?entityId=a1b2c3d4-e5f6-7890-abcd-ef { "id": "f7a1b2c3-d4e5-6789-0abc-def123456789", "name": "sales-orders-contract", - "fullyQualifiedName": "sales-orders-contract", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "description": "Data contract for the sales orders table", - "entityStatus": "Active", + "entityStatus": "Approved", "entity": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "type": "table", @@ -120,12 +120,15 @@ curl "{base_url}/api/v1/dataContracts/entity?entityId=a1b2c3d4-e5f6-7890-abcd-ef {"name": "customer_id", "dataType": "INT", "constraint": "NOT_NULL"} ], "semantics": [ - {"name": "hasOwner"}, - {"name": "hasDescription"} + { + "name": "Owners is set", + "description": "The table must have an owner.", + "rule": "{\"and\":[{\"some\":[{\"var\":\"owners\"},{\"!=\":[{\"var\":\"fullyQualifiedName\"},null]}]}]}", + "enabled": true + } ], "sla": { - "refreshFrequency": "PT1H", - "availability": 99.9 + "refreshFrequency": {"interval": 1, "unit": "day"} }, "owners": [], "reviewers": [], @@ -154,7 +157,7 @@ curl "{base_url}/api/v1/dataContracts/entity?entityId=a1b2c3d4-e5f6-7890-abcd-ef - Contract status: `Draft`, `Active`, or `Deprecated`. + Contract status: `Draft`, `In Review`, `Approved`, `Rejected`, `Deprecated`, or `Archived`. @@ -174,7 +177,7 @@ curl "{base_url}/api/v1/dataContracts/entity?entityId=a1b2c3d4-e5f6-7890-abcd-ef - SLA expectations (refresh frequency, latency, availability). + SLA expectations (refresh frequency, maximum latency, availability time, time zone, and retention). diff --git a/v1.13.x/api-reference/data-contracts/update.mdx b/v1.13.x/api-reference/data-contracts/update.mdx index 08f12b676..834d1b5a8 100644 --- a/v1.13.x/api-reference/data-contracts/update.mdx +++ b/v1.13.x/api-reference/data-contracts/update.mdx @@ -30,11 +30,10 @@ configure( ) # Update contract description and status -contract = DataContracts.update( - "f7a1b2c3-d4e5-6789-0abc-def123456789", - description="Updated contract for sales orders table", - entityStatus="Active" -) +contract = DataContracts.retrieve("f7a1b2c3-d4e5-6789-0abc-def123456789") +contract.description = "Updated contract for sales orders table" +contract.entityStatus = "Approved" +contract = DataContracts.update(contract) ``` ```java PATCH /v1/dataContracts/{id} @@ -43,7 +42,7 @@ import static org.openmetadata.sdk.fluent.DataContracts.*; // Update using fluent API FluentDataContract contract = find(contractId).fetch(); contract.withDescription("Updated contract for sales orders table") - .withStatus(EntityStatus.ACTIVE) + .withStatus(EntityStatus.APPROVED) .save(); ``` @@ -54,7 +53,7 @@ curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456 -H "Content-Type: application/json-patch+json" \ -d '[ {"op": "replace", "path": "/description", "value": "Updated contract for sales orders table"}, - {"op": "replace", "path": "/entityStatus", "value": "Active"} + {"op": "replace", "path": "/entityStatus", "value": "Approved"} ]' # Add a semantic rule @@ -72,9 +71,9 @@ curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456 { "id": "f7a1b2c3-d4e5-6789-0abc-def123456789", "name": "sales-orders-contract", - "fullyQualifiedName": "sales-orders-contract", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "description": "Updated contract for sales orders table", - "entityStatus": "Active", + "entityStatus": "Approved", "entity": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "type": "table", @@ -87,7 +86,7 @@ curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456 "changeDescription": { "fieldsUpdated": [ {"name": "description", "oldValue": "Data contract for the sales orders table", "newValue": "Updated contract for sales orders table"}, - {"name": "entityStatus", "oldValue": "Draft", "newValue": "Active"} + {"name": "entityStatus", "oldValue": "Draft", "newValue": "Approved"} ] } } @@ -101,7 +100,7 @@ curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456 | Operation | Path | Description | |-----------|------|-------------| | `replace` | `/description` | Update description | -| `replace` | `/entityStatus` | Change status (`Draft`, `Active`, `Deprecated`) | +| `replace` | `/entityStatus` | Change status (`Draft`, `In Review`, `Approved`, `Rejected`, `Deprecated`, `Archived`) | | `add` | `/semantics/-` | Add a semantic rule | | `remove` | `/semantics/0` | Remove a semantic rule by index | | `replace` | `/sla` | Update SLA section | diff --git a/v1.13.x/api-reference/data-contracts/validate.mdx b/v1.13.x/api-reference/data-contracts/validate.mdx index 4afb6d338..66cc632e4 100644 --- a/v1.13.x/api-reference/data-contracts/validate.mdx +++ b/v1.13.x/api-reference/data-contracts/validate.mdx @@ -7,7 +7,7 @@ api: POST /v1/dataContracts/{id}/validate # Validate & Results -Run on-demand validation of data contracts and manage execution results. Validation checks schema compliance, semantics rules, quality expectations, and SLA targets. +Run on-demand validation of data contracts and manage execution results. Validation checks schema compliance, semantics rules, and quality expectations. ## Validate a Contract @@ -30,35 +30,35 @@ Validate the effective contract for a specific entity. If the entity only has an - Type of the entity (e.g., `table`, `topic`). + Type of the entity, for example `table`, `topic`. ```python POST /v1/dataContracts/{id}/validate -from metadata.sdk import configure, get_client +from metadata.sdk import client, configure from metadata.sdk.entities import DataContracts configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Validate a specific contract -result = client.post( - f"/dataContracts/{contract_id}/validate" -) +result = rest.post("/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/validate") print(f"Status: {result['contractExecutionStatus']}") # Validate by entity -result = client.post("/dataContracts/entity/validate", params={ - "entityId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "entityType": "table" -}) +result = DataContracts.validate_by_entity( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + "table" +) +print(f"Status: {result.contractExecutionStatus}") ``` ```java POST /v1/dataContracts/{id}/validate import static org.openmetadata.sdk.fluent.DataContracts.*; +import org.openmetadata.schema.entity.datacontract.DataContractResult; // Validate a contract DataContractResult result = forContract(contractId).validate(); @@ -66,7 +66,7 @@ System.out.println("Status: " + result.getContractExecutionStatus()); // Or from a loaded contract FluentDataContract contract = find(contractId).fetch(); -DataContractResult result = contract.validate(); +DataContractResult sameResult = contract.validate(); ``` ```bash POST /v1/dataContracts/{id}/validate @@ -84,7 +84,7 @@ curl -X POST "{base_url}/api/v1/dataContracts/entity/validate?entityId=a1b2c3d4- ```json Response (Validation Result) { "id": "e1f2a3b4-c5d6-7890-ef12-345678901234", - "dataContractFQN": "sales-orders-contract", + "dataContractFQN": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "timestamp": 1769986400000, "contractExecutionStatus": "Success", "schemaValidation": { @@ -105,11 +105,6 @@ curl -X POST "{base_url}/api/v1/dataContracts/entity/validate?entityId=a1b2c3d4- "total": 2, "qualityScore": 100.0 }, - "slaValidation": { - "refreshFrequencyMet": true, - "latencyMet": true, - "availabilityMet": true - }, "executionTime": 1250 } ``` @@ -166,6 +161,10 @@ Programmatically add a validation result (useful for external validation pipelin ### Body Parameters + + Fully qualified name of the data contract the result belongs to. + + Epoch timestamp (milliseconds) of the validation run. @@ -212,7 +211,7 @@ Programmatically add a validation result (useful for external validation pipelin - SLA validation details. + SLA validation details. OpenMetadata doesn't fill this in during validation. External pipelines can set it. Whether refresh frequency target was met. @@ -227,16 +226,17 @@ Programmatically add a validation result (useful for external validation pipelin ```python Add Result -from metadata.sdk import configure, get_client +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Add a validation result -client.put(f"/dataContracts/{contract_id}/results", json={ +rest.put("/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/results", json={ + "dataContractFQN": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "timestamp": 1769986400000, "contractExecutionStatus": "Success", "schemaValidation": {"passed": 4, "failed": 0, "total": 4}, @@ -262,6 +262,7 @@ curl -X PUT "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def12345678 -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ + "dataContractFQN": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "timestamp": 1769986400000, "contractExecutionStatus": "Success", "schemaValidation": {"passed": 4, "failed": 0, "total": 4, "failedFields": []}, diff --git a/v1.13.x/api-reference/data-contracts/versions.mdx b/v1.13.x/api-reference/data-contracts/versions.mdx index 0dd9e0968..f8917e3b1 100644 --- a/v1.13.x/api-reference/data-contracts/versions.mdx +++ b/v1.13.x/api-reference/data-contracts/versions.mdx @@ -20,32 +20,37 @@ Every change to a data contract creates a new version. Use the versions API to l Use `GET /v1/dataContracts/{id}/versions/{version}` to retrieve a specific version. - Version number in `major.minor` format (e.g., `0.1`, `0.2`, `1.0`). + Version number in `major.minor` format, for example `0.1`, `0.2`, `1.0`. ```python GET /v1/dataContracts/{id}/versions -from metadata.sdk import configure +import json + +from metadata.sdk import client, configure from metadata.sdk.entities import DataContracts configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client # List all versions -versions = DataContracts.list_versions("f7a1b2c3-d4e5-6789-0abc-def123456789") -for v in versions: - print(f"v{v.version}: {v.updatedBy} at {v.updatedAt}") +history = rest.get("/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/versions") +for item in history["versions"]: + v = json.loads(item) + print(f"v{v['version']}: {v['updatedBy']} at {v['updatedAt']}") # Get specific version -contract_v1 = DataContracts.get_version( +contract_v1 = DataContracts.get_specific_version( "f7a1b2c3-d4e5-6789-0abc-def123456789", "0.1" ) ``` ```java GET /v1/dataContracts/{id}/versions +// client is an initialized OpenMetadataClient. // List versions using the client var history = client.dataContracts().listVersions(contractId); for (var version : history.getVersions()) { @@ -69,7 +74,7 @@ curl "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/versi { "entityType": "dataContract", "versions": [ - "{\"id\":\"f7a1b2c3-d4e5-6789-0abc-def123456789\",\"name\":\"sales-orders-contract\",\"version\":0.2,\"entityStatus\":\"Active\"}", + "{\"id\":\"f7a1b2c3-d4e5-6789-0abc-def123456789\",\"name\":\"sales-orders-contract\",\"version\":0.2,\"entityStatus\":\"Approved\"}", "{\"id\":\"f7a1b2c3-d4e5-6789-0abc-def123456789\",\"name\":\"sales-orders-contract\",\"version\":0.1,\"entityStatus\":\"Draft\"}" ] } @@ -83,7 +88,7 @@ curl "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/versi | Change Type | Version Impact | Example | |-------------|----------------|---------| | Minor field updates (description, display name) | Minor bump (`0.1` → `0.2`) | Update description | -| Major structural changes (status, schema, entity) | Major bump (`0.2` → `1.0`) | Change status to Active | +| Major structural changes (status, schema, entity) | Major bump (`0.2` → `1.0`) | Change status to Approved | --- diff --git a/v1.13.x/api-reference/data-quality/test-cases/create.mdx b/v1.13.x/api-reference/data-quality/test-cases/create.mdx index 34a77be8d..888bb4bba 100644 --- a/v1.13.x/api-reference/data-quality/test-cases/create.mdx +++ b/v1.13.x/api-reference/data-quality/test-cases/create.mdx @@ -109,13 +109,13 @@ request = CreateTestCaseRequest( ) test_case = TestCases.create(request) -print(f"Created: {test_case.fullyQualifiedName}") +print(f"Created: {test_case.fullyQualifiedName.root}") ``` ```java POST /v1/dataQuality/testCases import org.openmetadata.sdk.fluent.builders.TestCaseBuilder; -// Use an initialized OpenMetadataClient named client. +// client is an initialized OpenMetadataClient. var testCase = TestCaseBuilder.create(client) .name("column_value_max_to_be_between") .testDefinition("columnValueMaxToBeBetween") diff --git a/v1.13.x/api-reference/data-quality/test-cases/delete.mdx b/v1.13.x/api-reference/data-quality/test-cases/delete.mdx index 6573e1f6b..c63f62160 100644 --- a/v1.13.x/api-reference/data-quality/test-cases/delete.mdx +++ b/v1.13.x/api-reference/data-quality/test-cases/delete.mdx @@ -67,27 +67,34 @@ TestCases.delete( ) # Delete by name -TestCases.delete_by_name( - "sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between" +test_case = TestCases.retrieve_by_name( + "sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between", + fields=["testDefinition", "testSuite"] ) +TestCases.delete(test_case.id) # Restore a soft-deleted test case TestCases.restore("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") ``` ```java DELETE /v1/dataQuality/testCases/{id} -import static org.openmetadata.sdk.fluent.TestCases.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "c1bce355-fa2f-48c6-ab4d-fad722a56ed7"; // Soft delete -TestCases.delete("c1bce355-fa2f-48c6-ab4d-fad722a56ed7").execute(); +client.testCases().delete(id); + +// Restore +client.testCases().restore(id); // Hard delete -TestCases.delete("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") - .hardDelete() - .execute(); +client.testCases().delete(id, Map.of("hardDelete", "true")); -// Restore -TestCases.restore("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); +// Delete by name: look up the ID first +var testCase = client.testCases().getByName("sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between"); +client.testCases().delete(testCase.getId().toString()); ``` ```bash DELETE /v1/dataQuality/testCases/{id} diff --git a/v1.13.x/api-reference/data-quality/test-cases/list.mdx b/v1.13.x/api-reference/data-quality/test-cases/list.mdx index 0674393b9..fe4a50cde 100644 --- a/v1.13.x/api-reference/data-quality/test-cases/list.mdx +++ b/v1.13.x/api-reference/data-quality/test-cases/list.mdx @@ -58,50 +58,52 @@ configure( ) # List first page -cases = TestCases.list(limit=50) -for tc in cases.data: - print(f"{tc.fullyQualifiedName}") +cases = TestCases.list(fields=["testDefinition", "testSuite"], limit=50) +for tc in cases.entities: + print(f"{tc.fullyQualifiedName.root}") # List all with auto-pagination -for tc in TestCases.list_all(): - print(f"{tc.name}: {tc.entityLink}") +for tc in TestCases.list_all(fields=["testDefinition", "testSuite"]): + print(f"{tc.name.root}: {tc.entityLink.root}") # Filter by test suite cases = TestCases.list( - testSuiteId="e86a9a11-852f-4bac-b5a7-993b2bbbb572", - fields=["owners", "testDefinition", "testCaseResult"], + filters={"testSuiteId": "e86a9a11-852f-4bac-b5a7-993b2bbbb572"}, + fields=["owners", "testDefinition", "testSuite", "testCaseResult"], limit=50 ) -for tc in cases.data: - print(f"{tc.name} - {tc.testDefinition.name}") +for tc in cases.entities: + print(f"{tc.name.root} - {tc.testDefinition.name}") # Filter by entity link cases = TestCases.list( - entityLink="<#E::table::sample_data.ecommerce_db.shopify.dim_address>", - fields=["testCaseResult"], + filters={"entityLink": "<#E::table::sample_data.ecommerce_db.shopify.dim_address>"}, + fields=["testDefinition", "testSuite", "testCaseResult"], limit=50 ) ``` ```java GET /v1/dataQuality/testCases -import static org.openmetadata.sdk.fluent.TestCases.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = TestCases.list() - .limit(50) - .execute(); - -for (var tc : result.getData()) { - System.out.println(tc.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.testCases().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } -// Filter by test suite -var result = TestCases.list() - .testSuiteId("e86a9a11-852f-4bac-b5a7-993b2bbbb572") - .fields("owners", "testDefinition", "testCaseResult") - .limit(50) - .execute(); +// Filter by test suite with fields +var filtered = new ListParams() + .addFilter("testSuiteId", "e86a9a11-852f-4bac-b5a7-993b2bbbb572") + .setFields("testCaseResult,testDefinition") + .setLimit(50); +var filteredPage = client.testCases().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/dataQuality/testCases diff --git a/v1.13.x/api-reference/data-quality/test-cases/retrieve.mdx b/v1.13.x/api-reference/data-quality/test-cases/retrieve.mdx index e73bf1ca2..de5188777 100644 --- a/v1.13.x/api-reference/data-quality/test-cases/retrieve.mdx +++ b/v1.13.x/api-reference/data-quality/test-cases/retrieve.mdx @@ -28,7 +28,7 @@ Get a single test case by its unique ID or fully qualified name. Use `GET /v1/dataQuality/testCases/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the test case (e.g., `sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between`). + Fully qualified name of the test case, for example `sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between`. @@ -51,7 +51,7 @@ configure( # Get by ID tc = TestCases.retrieve("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") -print(f"{tc.fullyQualifiedName}: {tc.entityLink}") +print(f"{tc.fullyQualifiedName.root}: {tc.entityLink.root}") # Get by ID with fields tc = TestCases.retrieve( @@ -72,16 +72,21 @@ tc = TestCases.retrieve_by_name( ``` ```java GET /v1/dataQuality/testCases/{id} -import static org.openmetadata.sdk.fluent.TestCases.*; +// client is an initialized OpenMetadataClient. +var testCase = client.testCases().get("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); -// Get by ID -var tc = TestCases.retrieve("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); +// Get by ID with fields +var testCaseWithFields = client.testCases().get( + "c1bce355-fa2f-48c6-ab4d-fad722a56ed7", + "testCaseResult,testDefinition"); + +// Get by fully qualified name +var testCaseByName = client.testCases().getByName("sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between"); // Get by name with fields -var tc = TestCases.retrieveByName( +var testCaseByNameWithFields = client.testCases().getByName( "sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between", - "testCaseResult,testDefinition" -); + "testCaseResult,testDefinition"); ``` ```bash GET /v1/dataQuality/testCases/{id} diff --git a/v1.13.x/api-reference/data-quality/test-cases/update.mdx b/v1.13.x/api-reference/data-quality/test-cases/update.mdx index a0f3190ce..c85b5b34f 100644 --- a/v1.13.x/api-reference/data-quality/test-cases/update.mdx +++ b/v1.13.x/api-reference/data-quality/test-cases/update.mdx @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -78,15 +78,16 @@ tc.parameterValues = [ ] updated = TestCases.update(tc) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dataQuality/testCases/{id} -import static org.openmetadata.sdk.fluent.TestCases.*; +// client is an initialized OpenMetadataClient. +var testCaseId = "c1bce355-fa2f-48c6-ab4d-fad722a56ed7"; +var testCase = client.testCases().get(testCaseId); +testCase.setDescription("Updated: Validates shop_id max value stays between 1 and 200"); -var tc = TestCases.retrieve("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); -tc.setDescription("Updated: Validates shop_id max value stays between 1 and 200"); -var updated = TestCases.update(tc); +var updated = client.testCases().update(testCaseId, testCase); ``` ```bash PATCH /v1/dataQuality/testCases/{id} diff --git a/v1.13.x/api-reference/data-quality/test-cases/versions.mdx b/v1.13.x/api-reference/data-quality/test-cases/versions.mdx index 07c9db125..057c94282 100644 --- a/v1.13.x/api-reference/data-quality/test-cases/versions.mdx +++ b/v1.13.x/api-reference/data-quality/test-cases/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dataQuality/testCases/{id}/versions/{version}` to retrieve a specif - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dataQuality/testCases/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import TestCases @@ -40,7 +42,8 @@ configure( # List all versions versions = TestCases.get_versions("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version tc_v1 = TestCases.get_specific_version( @@ -51,20 +54,18 @@ print(f"Original params: {tc_v1.parameterValues}") ``` ```java GET /v1/dataQuality/testCases/{id}/versions -import static org.openmetadata.sdk.fluent.TestCases.*; +// client is an initialized OpenMetadataClient. +var id = "c1bce355-fa2f-48c6-ab4d-fad722a56ed7"; // List all versions -var history = TestCases.getVersions("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); - +var history = client.testCases().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = TestCases.getSpecificVersion( - "c1bce355-fa2f-48c6-ab4d-fad722a56ed7", - 0.1 -); +var v1 = client.testCases().getVersion(id, 0.1); +System.out.println(v1.getDescription()); ``` ```bash GET /v1/dataQuality/testCases/{id}/versions diff --git a/v1.13.x/api-reference/data-quality/test-definitions/create.mdx b/v1.13.x/api-reference/data-quality/test-definitions/create.mdx index e3ffbd9d0..7ff8a65ac 100644 --- a/v1.13.x/api-reference/data-quality/test-definitions/create.mdx +++ b/v1.13.x/api-reference/data-quality/test-definitions/create.mdx @@ -32,7 +32,7 @@ Create a custom test definition to define organization-specific data quality val - Array of data types this test can be applied to (e.g., `STRING`, `INT`, `DOUBLE`, `VARCHAR`, `CHAR`, `TEXT`, `NUMBER`, `FLOAT`, `BOOLEAN`). Only applicable when `entityType` is `COLUMN`. + Array of data types this test can be applied to, for example `STRING`, `INT`, `DOUBLE`, `VARCHAR`, `CHAR`, `TEXT`, `NUMBER`, `FLOAT`, `BOOLEAN`. Only applicable when `entityType` is `COLUMN`. @@ -44,7 +44,7 @@ Create a custom test definition to define organization-specific data quality val - Data type of the parameter (e.g., `INT`, `STRING`, `BOOLEAN`, `ARRAY`, `TABLE`). + Data type of the parameter, for example `INT`, `STRING`, `BOOLEAN`, `ARRAY`, `TABLE`. @@ -92,7 +92,7 @@ Create a custom test definition to define organization-specific data quality val - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -136,21 +136,40 @@ request = CreateTestDefinitionRequest( ) test_def = TestDefinitions.create(request) -print(f"Created: {test_def.name}") +print(f"Created: {test_def.name.root}") ``` ```java POST /v1/dataQuality/testDefinitions -import static org.openmetadata.sdk.fluent.TestDefinitions.*; import java.util.List; - -var testDef = TestDefinitions.builder() - .name("columnValuesToMatchBusinessRule") - .displayName("Column Values To Match Business Rule") - .description("Validates that column values conform to a custom business rule regex pattern") - .entityType("COLUMN") - .testPlatforms(List.of("OpenMetadata")) - .supportedDataTypes(List.of("STRING", "VARCHAR", "TEXT")) - .create(); +import org.openmetadata.schema.api.tests.CreateTestDefinition; +import org.openmetadata.schema.tests.TestCaseParameter; +import org.openmetadata.schema.tests.TestPlatform; +import org.openmetadata.schema.type.ColumnDataType; +import org.openmetadata.schema.type.TestCaseParameterDataType; +import org.openmetadata.schema.type.TestDefinitionEntityType; + +// client is an initialized OpenMetadataClient. +var request = new CreateTestDefinition() + .withName("columnValuesToMatchBusinessRule") + .withDisplayName("Column Values To Match Business Rule") + .withDescription("Validates that column values conform to a custom business rule regex pattern") + .withEntityType(TestDefinitionEntityType.COLUMN) + .withTestPlatforms(List.of(TestPlatform.OPEN_METADATA)) + .withSupportedDataTypes(List.of( + ColumnDataType.STRING, ColumnDataType.VARCHAR, ColumnDataType.TEXT)) + .withParameterDefinition(List.of( + new TestCaseParameter() + .withName("regexPattern") + .withDataType(TestCaseParameterDataType.STRING) + .withRequired(true) + .withDescription("The regex pattern to match against"), + new TestCaseParameter() + .withName("threshold") + .withDataType(TestCaseParameterDataType.INT) + .withRequired(false) + .withDescription("Maximum number of non-matching values allowed"))); + +var testDefinition = client.testDefinitions().create(request); ``` ```bash POST /v1/dataQuality/testDefinitions diff --git a/v1.13.x/api-reference/data-quality/test-definitions/list.mdx b/v1.13.x/api-reference/data-quality/test-definitions/list.mdx index e25f6995f..b93f3888c 100644 --- a/v1.13.x/api-reference/data-quality/test-definitions/list.mdx +++ b/v1.13.x/api-reference/data-quality/test-definitions/list.mdx @@ -32,7 +32,7 @@ List all test definitions with optional filtering and pagination. - Filter by test platform (e.g., `OpenMetadata`). + Filter by test platform, for example `OpenMetadata`. @@ -40,7 +40,7 @@ List all test definitions with optional filtering and pagination. - Filter by supported data type (e.g., `STRING`, `INT`, `DOUBLE`). + Filter by supported data type, for example `STRING`, `INT`, `DOUBLE`. @@ -55,41 +55,43 @@ configure( # List first page definitions = TestDefinitions.list(limit=50) -for td in definitions.data: - print(f"{td.name} ({td.entityType})") +for td in definitions.entities: + print(f"{td.name.root} ({td.entityType.value})") # List all with auto-pagination for td in TestDefinitions.list_all(): - print(f"{td.name}: {td.description}") + print(f"{td.name.root}: {td.description.root}") # Filter by entity type column_defs = TestDefinitions.list( - entityType="COLUMN", + filters={"entityType": "COLUMN"}, fields=["owners"], limit=50 ) -for td in column_defs.data: - print(f"{td.name} - supports: {td.supportedDataTypes}") +for td in column_defs.entities: + print(f"{td.name.root} - supports: {td.supportedDataTypes}") ``` ```java GET /v1/dataQuality/testDefinitions -import static org.openmetadata.sdk.fluent.TestDefinitions.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = TestDefinitions.list() - .limit(50) - .execute(); - -for (var td : result.getData()) { - System.out.println(td.getName() + " (" + td.getEntityType() + ")"); +var params = new ListParams().setLimit(50); +var page = client.testDefinitions().list(params); +for (var item : page.getData()) { + System.out.println(item.getName()); } // Filter by entity type -var result = TestDefinitions.list() - .entityType("COLUMN") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("entityType", "COLUMN") + .setLimit(50); +var filteredPage = client.testDefinitions().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getName()); +} ``` ```bash GET /v1/dataQuality/testDefinitions @@ -186,7 +188,7 @@ Returns a paginated list of test definition objects. Use the `fields` parameter - Supported test platforms (e.g., `OpenMetadata`). + Supported test platforms, for example `OpenMetadata`. @@ -202,7 +204,7 @@ Returns a paginated list of test definition objects. Use the `fields` parameter - Data type of the parameter (e.g., `INT`, `STRING`, `BOOLEAN`). + Data type of the parameter, for example `INT`, `STRING`, `BOOLEAN`. diff --git a/v1.13.x/api-reference/data-quality/test-definitions/retrieve.mdx b/v1.13.x/api-reference/data-quality/test-definitions/retrieve.mdx index 47c77ff3b..02acfc373 100644 --- a/v1.13.x/api-reference/data-quality/test-definitions/retrieve.mdx +++ b/v1.13.x/api-reference/data-quality/test-definitions/retrieve.mdx @@ -16,7 +16,7 @@ Get a single test definition by its unique ID or name. - Comma-separated list of fields to include (e.g., `owners`). + Comma-separated list of fields to include, for example `owners`. @@ -28,7 +28,7 @@ Get a single test definition by its unique ID or name. Use `GET /v1/dataQuality/testDefinitions/name/{name}` to retrieve by name. - Name of the test definition (e.g., `columnValueLengthsToBeBetween`). + Name of the test definition, for example `columnValueLengthsToBeBetween`. @@ -51,7 +51,7 @@ configure( # Get by ID td = TestDefinitions.retrieve("a636d153-f1e8-45be-86d3-52aa6b71730d") -print(f"{td.name}: {td.description}") +print(f"{td.name.root}: {getattr(td.description, 'root', td.description)}") # Get by ID with fields td = TestDefinitions.retrieve( @@ -66,13 +66,11 @@ print(f"Parameters: {[p.name for p in td.parameterDefinition]}") ``` ```java GET /v1/dataQuality/testDefinitions/{id} -import static org.openmetadata.sdk.fluent.TestDefinitions.*; +// client is an initialized OpenMetadataClient. +var testDefinition = client.testDefinitions().get("a636d153-f1e8-45be-86d3-52aa6b71730d"); -// Get by ID -var td = TestDefinitions.retrieve("a636d153-f1e8-45be-86d3-52aa6b71730d"); - -// Get by name -var td = TestDefinitions.retrieveByName("columnValueLengthsToBeBetween"); +// Get by fully qualified name +var testDefinitionByName = client.testDefinitions().getByName("columnValueLengthsToBeBetween"); ``` ```bash GET /v1/dataQuality/testDefinitions/{id} diff --git a/v1.13.x/api-reference/data-quality/test-suites/create.mdx b/v1.13.x/api-reference/data-quality/test-suites/create.mdx index 947d3dc0e..27e76cf08 100644 --- a/v1.13.x/api-reference/data-quality/test-suites/create.mdx +++ b/v1.13.x/api-reference/data-quality/test-suites/create.mdx @@ -66,12 +66,14 @@ request = CreateTestSuiteRequest( ) test_suite = TestSuites.create(request) -print(f"Created: {test_suite.name}") +print(f"Created: {test_suite.name.root}") ``` ```java POST /v1/dataQuality/testSuites import org.openmetadata.sdk.fluent.builders.TestSuiteBuilder; +// client is an initialized OpenMetadataClient. + // Create a logical test suite // Use an initialized OpenMetadataClient named client. var testSuite = new TestSuiteBuilder(client) diff --git a/v1.13.x/api-reference/data-quality/test-suites/delete.mdx b/v1.13.x/api-reference/data-quality/test-suites/delete.mdx index ab805609b..c46c667a0 100644 --- a/v1.13.x/api-reference/data-quality/test-suites/delete.mdx +++ b/v1.13.x/api-reference/data-quality/test-suites/delete.mdx @@ -67,25 +67,30 @@ TestSuites.delete( ) # Delete by name -TestSuites.delete_by_name("b5fcae09-02c2-4c0b-8c4a-5b52d650e592") +TestSuites.delete(TestSuites.retrieve_by_name("sample_data.ecommerce_db.shopify.dim_address.testSuite").id) # Restore a soft-deleted test suite TestSuites.restore("e86a9a11-852f-4bac-b5a7-993b2bbbb572") ``` ```java DELETE /v1/dataQuality/testSuites/{id} -import static org.openmetadata.sdk.fluent.TestSuites.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "e86a9a11-852f-4bac-b5a7-993b2bbbb572"; // Soft delete -TestSuites.delete("e86a9a11-852f-4bac-b5a7-993b2bbbb572").execute(); +client.testSuites().delete(id); + +// Restore +client.testSuites().restore(id); // Hard delete -TestSuites.delete("e86a9a11-852f-4bac-b5a7-993b2bbbb572") - .hardDelete() - .execute(); +client.testSuites().delete(id, Map.of("hardDelete", "true")); -// Restore -TestSuites.restore("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); +// Delete by name: look up the ID first +var testSuite = client.testSuites().getByName("sample_data.ecommerce_db.shopify.dim_address.testSuite"); +client.testSuites().delete(testSuite.getId().toString()); ``` ```bash DELETE /v1/dataQuality/testSuites/{id} @@ -98,7 +103,7 @@ curl -X DELETE "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7 -H "Authorization: Bearer {access_token}" # Delete by name -curl -X DELETE "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52d650e592" \ +curl -X DELETE "{base_url}/api/v1/dataQuality/testSuites/name/sample_data.ecommerce_db.shopify.dim_address.testSuite" \ -H "Authorization: Bearer {access_token}" # Restore soft-deleted test suite @@ -113,15 +118,15 @@ curl -X PUT "{base_url}/api/v1/dataQuality/testSuites/restore" \ ```json Response (Soft Delete) { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "version": 0.2, "updatedAt": 1769982800000, "updatedBy": "admin", "deleted": true, "owners": [], - "executable": true + "basic": true } ``` diff --git a/v1.13.x/api-reference/data-quality/test-suites/list.mdx b/v1.13.x/api-reference/data-quality/test-suites/list.mdx index 4e2742e3d..37e60d98a 100644 --- a/v1.13.x/api-reference/data-quality/test-suites/list.mdx +++ b/v1.13.x/api-reference/data-quality/test-suites/list.mdx @@ -32,7 +32,7 @@ List all test suites with optional filtering and pagination. - Filter by test suite type: `executable` or `logical`. + Filter by test suite type, for example `logical`. The older value `executable` is still accepted. @@ -47,42 +47,44 @@ configure( # List first page suites = TestSuites.list(limit=50) -for ts in suites.data: - print(f"{ts.displayName} (executable: {ts.executable})") +for ts in suites.entities: + print(f"{ts.displayName} (basic: {ts.basic})") # List all with auto-pagination for ts in TestSuites.list_all(): - print(f"{ts.fullyQualifiedName}") + print(f"{ts.fullyQualifiedName.root}") # Filter by type logical_suites = TestSuites.list( - testSuiteType="logical", + filters={"testSuiteType": "logical"}, fields=["owners", "tests"], limit=50 ) -for ts in logical_suites.data: +for ts in logical_suites.entities: print(f"{ts.displayName}") ``` ```java GET /v1/dataQuality/testSuites -import static org.openmetadata.sdk.fluent.TestSuites.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = TestSuites.list() - .limit(50) - .execute(); - -for (var ts : result.getData()) { - System.out.println(ts.getDisplayName()); +var params = new ListParams().setLimit(50); +var page = client.testSuites().list(params); +for (var item : page.getData()) { + System.out.println(item.getDisplayName()); } -// Filter by type -var result = TestSuites.list() - .testSuiteType("logical") - .fields("owners", "tests") - .limit(50) - .execute(); +// Filter by type with fields +var filtered = new ListParams() + .addFilter("testSuiteType", "logical") + .setFields("owners,tests") + .setLimit(50); +var filteredPage = client.testSuites().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getDisplayName()); +} ``` ```bash GET /v1/dataQuality/testSuites @@ -91,7 +93,7 @@ curl "{base_url}/api/v1/dataQuality/testSuites?limit=50" \ -H "Authorization: Bearer {access_token}" # Filter by type -curl "{base_url}/api/v1/dataQuality/testSuites?testSuiteType=executable&limit=50" \ +curl "{base_url}/api/v1/dataQuality/testSuites?testSuiteType=logical&limit=50" \ -H "Authorization: Bearer {access_token}" # With fields @@ -106,15 +108,15 @@ curl "{base_url}/api/v1/dataQuality/testSuites?fields=owners,tests&limit=50" \ "data": [ { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "version": 0.1, "updatedAt": 1769982757893, "updatedBy": "admin", "deleted": false, "owners": [], - "executable": true + "basic": true } ], "paging": { @@ -153,8 +155,8 @@ Returns a paginated list of test suite objects. Use the `fields` parameter to re Human-readable display name. - - Whether this is an executable or logical test suite. + + `true` for a table-level (basic) test suite, `false` for a logical test suite. diff --git a/v1.13.x/api-reference/data-quality/test-suites/retrieve.mdx b/v1.13.x/api-reference/data-quality/test-suites/retrieve.mdx index f57b6d414..f906e54ae 100644 --- a/v1.13.x/api-reference/data-quality/test-suites/retrieve.mdx +++ b/v1.13.x/api-reference/data-quality/test-suites/retrieve.mdx @@ -51,7 +51,7 @@ configure( # Get by ID ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572") -print(f"{ts.displayName} (executable: {ts.executable})") +print(f"{ts.displayName} (basic: {ts.basic})") # Get by ID with fields ts = TestSuites.retrieve( @@ -60,20 +60,25 @@ ts = TestSuites.retrieve( ) # Get by fully qualified name -ts = TestSuites.retrieve_by_name("b5fcae09-02c2-4c0b-8c4a-5b52d650e592") +ts = TestSuites.retrieve_by_name("sample_data.ecommerce_db.shopify.dim_address.testSuite") ``` ```java GET /v1/dataQuality/testSuites/{id} -import static org.openmetadata.sdk.fluent.TestSuites.*; +// client is an initialized OpenMetadataClient. +var testSuite = client.testSuites().get("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); -// Get by ID -var ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); +// Get by ID with fields +var testSuiteWithFields = client.testSuites().get( + "e86a9a11-852f-4bac-b5a7-993b2bbbb572", + "owners,tests"); + +// Get by fully qualified name +var testSuiteByName = client.testSuites().getByName("sample_data.ecommerce_db.shopify.dim_address.testSuite"); // Get by name with fields -var ts = TestSuites.retrieveByName( - "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", - "owners,tests" -); +var testSuiteByNameWithFields = client.testSuites().getByName( + "sample_data.ecommerce_db.shopify.dim_address.testSuite", + "owners,tests"); ``` ```bash GET /v1/dataQuality/testSuites/{id} @@ -86,7 +91,7 @@ curl "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7-993b2bbbb -H "Authorization: Bearer {access_token}" # Get by name -curl "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52d650e592" \ +curl "{base_url}/api/v1/dataQuality/testSuites/name/sample_data.ecommerce_db.shopify.dim_address.testSuite" \ -H "Authorization: Bearer {access_token}" ``` @@ -95,15 +100,15 @@ curl "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52 ```json Response { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "version": 0.1, "updatedAt": 1769982757893, "updatedBy": "admin", "deleted": false, "owners": [], - "executable": true + "basic": true } ``` @@ -136,8 +141,8 @@ Returns a test suite object with all requested fields populated. Description of the test suite. - - Whether this is an executable or logical test suite. + + `true` for a table-level (basic) test suite, `false` for a logical test suite. diff --git a/v1.13.x/api-reference/data-quality/test-suites/update.mdx b/v1.13.x/api-reference/data-quality/test-suites/update.mdx index 08ff81e81..ac37d5a1a 100644 --- a/v1.13.x/api-reference/data-quality/test-suites/update.mdx +++ b/v1.13.x/api-reference/data-quality/test-suites/update.mdx @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -64,16 +64,16 @@ ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572") ts.description = "Updated: Critical data quality checks for production tables" updated = TestSuites.update(ts) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dataQuality/testSuites/{id} -import static org.openmetadata.sdk.fluent.TestSuites.*; +// client is an initialized OpenMetadataClient. +var testSuiteId = "e86a9a11-852f-4bac-b5a7-993b2bbbb572"; +var testSuite = client.testSuites().get(testSuiteId); +testSuite.setDescription("Updated: Critical data quality checks for production tables"); -// Retrieve, modify, and update -var ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); -ts.setDescription("Updated: Critical data quality checks for production tables"); -var updated = TestSuites.update(ts); +var updated = client.testSuites().update(testSuiteId, testSuite); ``` ```bash PATCH /v1/dataQuality/testSuites/{id} @@ -86,7 +86,7 @@ curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7- ]' # Update by name -curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52d650e592" \ +curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/name/sample_data.ecommerce_db.shopify.dim_address.testSuite" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json-patch+json" \ -d '[ @@ -99,16 +99,16 @@ curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b- ```json Response { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "description": "Updated: Critical data quality checks for production tables", "version": 0.2, "updatedAt": 1769982800000, "updatedBy": "admin", "deleted": false, "owners": [], - "executable": true + "basic": true } ``` diff --git a/v1.13.x/api-reference/data-quality/test-suites/versions.mdx b/v1.13.x/api-reference/data-quality/test-suites/versions.mdx index 79e7b4dbf..6e5793a74 100644 --- a/v1.13.x/api-reference/data-quality/test-suites/versions.mdx +++ b/v1.13.x/api-reference/data-quality/test-suites/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dataQuality/testSuites/{id}/versions/{version}` to retrieve a speci - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dataQuality/testSuites/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import TestSuites @@ -40,31 +42,30 @@ configure( # List all versions versions = TestSuites.get_versions("e86a9a11-852f-4bac-b5a7-993b2bbbb572") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version ts_v1 = TestSuites.get_specific_version( "e86a9a11-852f-4bac-b5a7-993b2bbbb572", "0.1" ) -print(f"Original description: {ts_v1.description}") +print(f"Original description: {getattr(ts_v1.description, 'root', ts_v1.description)}") ``` ```java GET /v1/dataQuality/testSuites/{id}/versions -import static org.openmetadata.sdk.fluent.TestSuites.*; +// client is an initialized OpenMetadataClient. +var id = "e86a9a11-852f-4bac-b5a7-993b2bbbb572"; // List all versions -var history = TestSuites.getVersions("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); - +var history = client.testSuites().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = TestSuites.getSpecificVersion( - "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - 0.1 -); +var v1 = client.testSuites().getVersion(id, 0.1); +System.out.println(v1.getDescription()); ``` ```bash GET /v1/dataQuality/testSuites/{id}/versions @@ -83,8 +84,8 @@ curl "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7-993b2bbbb { "entityType": "testSuite", "versions": [ - "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"b5fcae09-02c2-4c0b-8c4a-5b52d650e592\",\"version\":0.2,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"description\":\"Updated description\",\"executable\":true}", - "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"b5fcae09-02c2-4c0b-8c4a-5b52d650e592\",\"version\":0.1,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"executable\":true}" + "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"sample_data.ecommerce_db.shopify.dim_address.testSuite\",\"version\":0.2,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"description\":\"Updated description\",\"basic\":true}", + "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"sample_data.ecommerce_db.shopify.dim_address.testSuite\",\"version\":0.1,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"basic\":true}" ] } ``` diff --git a/v1.13.x/api-reference/discovery/field-query.mdx b/v1.13.x/api-reference/discovery/field-query.mdx index 6c440f7ff..0c5990dd3 100644 --- a/v1.13.x/api-reference/discovery/field-query.mdx +++ b/v1.13.x/api-reference/discovery/field-query.mdx @@ -33,31 +33,35 @@ Search for entities by matching a specific field to a given value. This is usefu ```python GET /v1/search/fieldQuery -from metadata.sdk import configure, get_client +from urllib.parse import urlencode + +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Find tables with a specific column name -response = client.get("/search/fieldQuery", params={ +params = urlencode({ "fieldName": "columns.name", "fieldValue": "shop_id", "index": "table_search_index" }) +response = rest.get(f"/search/fieldQuery?{params}") for hit in response["hits"]["hits"]: entity = hit["_source"] print(f"{entity['fullyQualifiedName']} (score: {hit['_score']})") # Find entities with a specific tag -response = client.get("/search/fieldQuery", params={ +params = urlencode({ "fieldName": "tags.tagFQN", "fieldValue": "PII.Sensitive", "index": "table_search_index" }) +response = rest.get(f"/search/fieldQuery?{params}") for hit in response["hits"]["hits"]: entity = hit["_source"] @@ -65,6 +69,7 @@ for hit in response["hits"]["hits"]: ``` ```java GET /v1/search/fieldQuery +// client is an initialized OpenMetadataClient. // Find tables with a specific column name var response = client.searchApi().fieldQuery( "columns.name", // fieldName @@ -205,7 +210,7 @@ Returns an Elasticsearch-style response containing entities where the specified | Field Path | Description | Applicable Indexes | |------------|-------------|-------------------| | `columns.name` | Column name within a table | `table_search_index` | -| `tags.tagFQN` | Fully qualified tag name (e.g., `PII.Sensitive`) | All indexes | +| `tags.tagFQN` | Fully qualified tag name, for example `PII.Sensitive` | All indexes | | `owners.name` | Owner username | All indexes | | `service.name` | Service name | All entity indexes | | `database.name` | Database name | `table_search_index` | diff --git a/v1.13.x/api-reference/discovery/search.mdx b/v1.13.x/api-reference/discovery/search.mdx index ba66c99ca..0a26d0060 100644 --- a/v1.13.x/api-reference/discovery/search.mdx +++ b/v1.13.x/api-reference/discovery/search.mdx @@ -32,7 +32,7 @@ Full-text search across all entity types in the metadata catalog. Uses Elasticse - Field to sort by (e.g., `name`, `updatedAt`, `totalVotes`). + Field to sort by, for example `name`, `updatedAt`, `totalVotes`. @@ -65,21 +65,24 @@ Full-text search across all entity types in the metadata catalog. Uses Elasticse ```python GET /v1/search/query -from metadata.sdk import configure, get_client +from urllib.parse import urlencode + +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Search for tables matching "customer" -response = client.get("/search/query", params={ +params = urlencode({ "q": "customer", "index": "table_search_index", "from": 0, "size": 10 }) +response = rest.get(f"/search/query?{params}") for hit in response["hits"]["hits"]: entity = hit["_source"] @@ -87,6 +90,7 @@ for hit in response["hits"]["hits"]: ``` ```java GET /v1/search/query +// client is an initialized OpenMetadataClient. // Search using the OpenMetadata client var response = client.searchApi().searchEntities( "customer", // query @@ -207,7 +211,7 @@ Returns an Elasticsearch-style response containing matched entities ranked by re - Search index the result was found in (e.g., `table_search_index`). + Search index the result was found in, for example `table_search_index`. diff --git a/v1.13.x/api-reference/errors.mdx b/v1.13.x/api-reference/errors.mdx index 4356e8643..e2a6decea 100644 --- a/v1.13.x/api-reference/errors.mdx +++ b/v1.13.x/api-reference/errors.mdx @@ -278,15 +278,14 @@ except Exception as e: ``` ```java JAVA SDK -import org.openmetadata.client.api.TablesApi; -import org.openmetadata.client.ApiException; +import org.openmetadata.sdk.exceptions.OpenMetadataException; -TablesApi tablesApi = client.buildClient(TablesApi.class); +// client is an initialized OpenMetadataClient. try { - Table table = tablesApi.getTableByFQN("prod.analytics.customers", null, null); -} catch (ApiException e) { - switch (e.getCode()) { + var table = client.tables().getByName("prod.analytics.customers"); +} catch (OpenMetadataException e) { + switch (e.getStatusCode()) { case 404: System.out.println("Table not found"); break; diff --git a/v1.13.x/api-reference/getting-started.mdx b/v1.13.x/api-reference/getting-started.mdx index 364e1dc5a..de6848392 100644 --- a/v1.13.x/api-reference/getting-started.mdx +++ b/v1.13.x/api-reference/getting-started.mdx @@ -9,10 +9,14 @@ import BotsTileAdminNote from '/snippets/deployment/bots-tile-admin-note.mdx' Get up and running with the OpenMetadata API and SDKs. This guide walks you through authentication, SDK installation, and making your first API call. + +Most Python examples in this API reference use SDK 2.0 (`metadata.sdk`). The Topics and ML model services pages use the original client, because SDK 2.0 has no class for them. The pages under the SDK section also show the original client. For more information, see [Which Python SDK Should I Use?](/v1.13.x/api-reference/sdk/python/overview#which-python-sdk-should-i-use). + + ## Prerequisites - A OpenMetadata account (cloud or self-hosted instance) -- Your instance base URL (e.g., `https://your-company.open-metadata.org/api`) +- Your instance base URL, for example `https://your-company.open-metadata.org/api` - **Python 3.11+**, **Java 21+**, or **Go 1.19+** (depending on your SDK choice) @@ -81,23 +85,13 @@ Set up the connection to your OpenMetadata instance: ```python Python -from metadata.ingestion.ometa.ometa_api import OpenMetadata -from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( - OpenMetadataConnection, -) -from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( - OpenMetadataJWTClientConfig, -) +from metadata.sdk import configure -server_config = OpenMetadataConnection( - hostPort="https://your-company.open-metadata.org/api", - authProvider="openmetadata", - securityConfig=OpenMetadataJWTClientConfig( - jwtToken="your-jwt-token" - ), +# The host must end with /api +configure( + host="https://your-company.open-metadata.org/api", + jwt_token="your-jwt-token", ) - -metadata = OpenMetadata(server_config) ``` ```java Java @@ -115,15 +109,10 @@ OpenMetadataClient client = new OpenMetadataClient(config); ```go Go import ometa "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" -restConfig := ometa.NewRestConfig( +client := ometa.NewClient( "https://your-company.open-metadata.org", - "", // APIVersion - 0, // Retry -> defaults to 3 - 0, // RetryWait -> defaults to 30 seconds - nil, // RetryCodes -> defaults to [429, 504] - "your-jwt-token", + ometa.WithToken("your-jwt-token"), ) -client, err := ometa.NewRest(restConfig) ``` ```bash cURL @@ -141,40 +130,32 @@ List the tables in your catalog to verify everything is working: ```python Python -from metadata.generated.schema.entity.data.table import Table +from metadata.sdk import Tables -tables = metadata.list_all_entities(entity=Table) -for table in tables: - print(f"{table.fullyQualifiedName}: {table.description}") +for table in Tables.list_all(): + print(f"{table.fullyQualifiedName.root}: {getattr(table.description, 'root', table.description)}") ``` ```java Java -TablesApi tablesApi = client.buildClient(TablesApi.class); -TableList tables = tablesApi.listTables(null, 10, null, null, null); +import org.openmetadata.sdk.models.ListParams; -for (Table table : tables.getData()) { +// client is an initialized OpenMetadataClient. + +var tables = client.tables().list(new ListParams().setLimit(10)); + +for (var table : tables.getData()) { System.out.println(table.getFullyQualifiedName()); } ``` ```go Go -resp, err := rest.Get("tables", map[string]string{"limit": "10"}) -if err != nil { - log.Fatal(err) -} -defer resp.Body.Close() +ctx := context.Background() -var result struct { - Data []struct { - FullyQualifiedName string `json:"fullyQualifiedName"` - } `json:"data"` -} -if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { - log.Fatal(err) -} - -for _, table := range result.Data { - fmt.Println(table.FullyQualifiedName) +for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(*table.FullyQualifiedName) } ``` @@ -224,7 +205,7 @@ from metadata.generated.schema.api.data.createTable import CreateTableRequest from metadata.generated.schema.entity.data.table import Column, DataType # Initialize the SDK -configure(host="https://your-company.open-metadata.org", jwt_token="your-jwt-token") +configure(host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token") # Create and persist the table table = Tables.create(CreateTableRequest( @@ -238,15 +219,15 @@ table = Tables.create(CreateTableRequest( ], )) -print(f"Created: {table.fullyQualifiedName}") +print(f"Created: {table.fullyQualifiedName.root}") ``` ```java Java -import org.openmetadata.sdk.client.OpenMetadataClient; -import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.schema.entity.data.Table; import org.openmetadata.sdk.fluent.builders.TableBuilder; import org.openmetadata.sdk.fluent.builders.ColumnBuilder; +// client is the OpenMetadataClient from the "Initialize Your Client" step. // Create and persist the table in one fluent chain Table table = new TableBuilder(client) .name("customers") diff --git a/v1.13.x/api-reference/governance/classifications/create.mdx b/v1.13.x/api-reference/governance/classifications/create.mdx index 706006bf0..a3855388f 100644 --- a/v1.13.x/api-reference/governance/classifications/create.mdx +++ b/v1.13.x/api-reference/governance/classifications/create.mdx @@ -36,7 +36,7 @@ Create a new classification for organizing tags into categories. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -67,18 +67,19 @@ request = CreateClassificationRequest( ) classification = Classifications.create(request) -print(f"Created: {classification.fullyQualifiedName}") +print(f"Created: {classification.fullyQualifiedName.root}") ``` ```java POST /v1/classifications -import static org.openmetadata.sdk.fluent.Classifications.*; - -// Create using builder pattern -var classification = Classifications.builder() - .name("Certification") - .description("Certifying Data Asset will provide the users with a clear idea of...") - .mutuallyExclusive(true) - .create(); +import org.openmetadata.schema.api.classification.CreateClassification; + +// client is an initialized OpenMetadataClient. +var request = new CreateClassification() + .withName("Certification") + .withDescription("Certifying Data Asset will provide the users with a clear idea of...") + .withMutuallyExclusive(true); + +var classification = client.classifications().create(request); ``` ```bash POST /v1/classifications diff --git a/v1.13.x/api-reference/governance/classifications/delete.mdx b/v1.13.x/api-reference/governance/classifications/delete.mdx index f1502e18d..662141382 100644 --- a/v1.13.x/api-reference/governance/classifications/delete.mdx +++ b/v1.13.x/api-reference/governance/classifications/delete.mdx @@ -28,7 +28,7 @@ Delete a classification by ID or fully qualified name. Supports soft delete (def Use `DELETE /v1/classifications/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the classification (e.g., `Certification`). + Fully qualified name of the classification, for example `Certification`. @@ -67,28 +67,30 @@ Classifications.delete( ) # Delete by name -Classifications.delete_by_name("Certification") +Classifications.delete(Classifications.retrieve_by_name("Certification").id) # Restore a soft-deleted classification Classifications.restore("06d90883-6be9-4f7e-9475-753f10a95e94") ``` ```java DELETE /v1/classifications/{id} -import static org.openmetadata.sdk.fluent.Classifications.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "06d90883-6be9-4f7e-9475-753f10a95e94"; // Soft delete -Classifications.delete("06d90883-6be9-4f7e-9475-753f10a95e94").execute(); +client.classifications().delete(id); -// Hard delete -Classifications.delete("06d90883-6be9-4f7e-9475-753f10a95e94") - .hardDelete() - .execute(); +// Restore +client.classifications().restore(id); -// Delete by name -Classifications.deleteByName("Certification").execute(); +// Hard delete +client.classifications().delete(id, Map.of("hardDelete", "true")); -// Restore -Classifications.restore("06d90883-6be9-4f7e-9475-753f10a95e94"); +// Delete by name: look up the ID first +var classification = client.classifications().getByName("Certification"); +client.classifications().delete(classification.getId().toString()); ``` ```bash DELETE /v1/classifications/{id} diff --git a/v1.13.x/api-reference/governance/classifications/list.mdx b/v1.13.x/api-reference/governance/classifications/list.mdx index 28e5770f3..43152296a 100644 --- a/v1.13.x/api-reference/governance/classifications/list.mdx +++ b/v1.13.x/api-reference/governance/classifications/list.mdx @@ -43,12 +43,12 @@ configure( # List first page classifications = Classifications.list(limit=50) -for c in classifications.data: - print(f"{c.fullyQualifiedName} (mutuallyExclusive: {c.mutuallyExclusive})") +for c in classifications.entities: + print(f"{c.fullyQualifiedName.root} (mutuallyExclusive: {c.mutuallyExclusive})") # List all with auto-pagination for c in Classifications.list_all(): - print(f"{c.fullyQualifiedName}") + print(f"{c.fullyQualifiedName.root}") # With fields classifications = Classifications.list( @@ -58,22 +58,24 @@ classifications = Classifications.list( ``` ```java GET /v1/classifications -import static org.openmetadata.sdk.fluent.Classifications.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Classifications.list() - .limit(50) - .execute(); - -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.classifications().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // With fields -var result = Classifications.list() - .fields("owners") - .limit(50) - .execute(); +var filtered = new ListParams() + .setFields("owners") + .setLimit(50); +var filteredPage = client.classifications().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/classifications diff --git a/v1.13.x/api-reference/governance/classifications/retrieve.mdx b/v1.13.x/api-reference/governance/classifications/retrieve.mdx index 75868f41c..e9e69d1a9 100644 --- a/v1.13.x/api-reference/governance/classifications/retrieve.mdx +++ b/v1.13.x/api-reference/governance/classifications/retrieve.mdx @@ -16,7 +16,7 @@ Get a single classification by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners`). + Comma-separated list of fields to include, for example `owners`. @@ -28,7 +28,7 @@ Get a single classification by its unique ID or fully qualified name. Use `GET /v1/classifications/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the classification (e.g., `Certification`). + Fully qualified name of the classification, for example `Certification`. @@ -51,7 +51,7 @@ configure( # Get by ID classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94") -print(f"{classification.fullyQualifiedName}: {classification.description}") +print(f"{classification.fullyQualifiedName.root}: {getattr(classification.description, 'root', classification.description)}") # Get by ID with fields classification = Classifications.retrieve( @@ -70,22 +70,21 @@ classification = Classifications.retrieve_by_name( ``` ```java GET /v1/classifications/{id} -import static org.openmetadata.sdk.fluent.Classifications.*; - -// Get by ID -var classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94"); +// client is an initialized OpenMetadataClient. +var classification = client.classifications().get("06d90883-6be9-4f7e-9475-753f10a95e94"); // Get by ID with fields -var classification = Classifications.retrieve( +var classificationWithFields = client.classifications().get( "06d90883-6be9-4f7e-9475-753f10a95e94", - "owners" -); + "owners"); // Get by fully qualified name -var classification = Classifications.retrieveByName("Certification"); +var classificationByName = client.classifications().getByName("Certification"); // Get by name with fields -var classification = Classifications.retrieveByName("Certification", "owners"); +var classificationByNameWithFields = client.classifications().getByName( + "Certification", + "owners"); ``` ```bash GET /v1/classifications/{id} diff --git a/v1.13.x/api-reference/governance/classifications/update.mdx b/v1.13.x/api-reference/governance/classifications/update.mdx index 98468f05b..870cb318b 100644 --- a/v1.13.x/api-reference/governance/classifications/update.mdx +++ b/v1.13.x/api-reference/governance/classifications/update.mdx @@ -20,7 +20,7 @@ Update a classification's properties using JSON Merge Patch. You can update by I Use `PATCH /v1/classifications/name/{fqn}` to update by fully qualified name. - Fully qualified name of the classification (e.g., `Certification`). + Fully qualified name of the classification, for example `Certification`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,16 +68,16 @@ classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94" classification.description = "Updated: Classification for data asset certification levels" updated = Classifications.update(classification) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/classifications/{id} -import static org.openmetadata.sdk.fluent.Classifications.*; - -// Retrieve, modify, and update -var classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94"); +// client is an initialized OpenMetadataClient. +var classificationId = "06d90883-6be9-4f7e-9475-753f10a95e94"; +var classification = client.classifications().get(classificationId); classification.setDescription("Updated: Classification for data asset certification levels"); -var updated = Classifications.update(classification); + +var updated = client.classifications().update(classificationId, classification); ``` ```bash PATCH /v1/classifications/{id} diff --git a/v1.13.x/api-reference/governance/classifications/versions.mdx b/v1.13.x/api-reference/governance/classifications/versions.mdx index d64423ddc..5ded3810d 100644 --- a/v1.13.x/api-reference/governance/classifications/versions.mdx +++ b/v1.13.x/api-reference/governance/classifications/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/classifications/{id}/versions/{version}` to retrieve a specific ver - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/classifications/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Classifications @@ -40,31 +42,29 @@ configure( # List all versions versions = Classifications.get_versions("06d90883-6be9-4f7e-9475-753f10a95e94") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version classification_v1 = Classifications.get_specific_version( "06d90883-6be9-4f7e-9475-753f10a95e94", "0.1" ) -print(f"Original description: {classification_v1.description}") +print(f"Original description: {getattr(classification_v1.description, 'root', classification_v1.description)}") ``` ```java GET /v1/classifications/{id}/versions -import static org.openmetadata.sdk.fluent.Classifications.*; +// client is an initialized OpenMetadataClient. +var id = "06d90883-6be9-4f7e-9475-753f10a95e94"; // List all versions -var history = Classifications.getVersions("06d90883-6be9-4f7e-9475-753f10a95e94"); - +var history = client.classifications().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Classifications.getSpecificVersion( - "06d90883-6be9-4f7e-9475-753f10a95e94", - 0.1 -); +var v1 = client.classifications().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/governance/data-products/create.mdx b/v1.13.x/api-reference/governance/data-products/create.mdx index e6d6b59a4..44124a47e 100644 --- a/v1.13.x/api-reference/governance/data-products/create.mdx +++ b/v1.13.x/api-reference/governance/data-products/create.mdx @@ -12,11 +12,11 @@ Create a new data product within a domain. ## Body Parameters - Name of the data product. Must be unique within the parent domain. + Name of the data product. Must be unique across all data products. - - Fully qualified name of the parent domain (e.g., `Marketing`). + + Fully qualified names of the parent domains, for example `["Marketing"]`. @@ -36,7 +36,7 @@ Create a new data product within a domain. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -76,24 +76,26 @@ configure( request = { "name": "CustomerInsights", "displayName": "Customer Insights", - "domain": "Marketing", + "domains": ["Marketing"], "description": "Curated customer analytics data product" } data_product = DataProducts.create(request) -print(f"Created: {data_product.fullyQualifiedName}") +print(f"Created: {data_product.fullyQualifiedName.root}") ``` ```java POST /v1/dataProducts -import static org.openmetadata.sdk.fluent.DataProducts.*; - -// Create using builder pattern -var dataProduct = DataProducts.builder() - .name("CustomerInsights") - .displayName("Customer Insights") - .domain("Marketing") - .description("Curated customer analytics data product") - .create(); +import java.util.List; +import org.openmetadata.schema.api.domains.CreateDataProduct; + +// client is an initialized OpenMetadataClient. +var request = new CreateDataProduct() + .withName("CustomerInsights") + .withDisplayName("Customer Insights") + .withDomains(List.of("Marketing")) + .withDescription("Curated customer analytics data product"); + +var dataProduct = client.dataProducts().create(request); ``` ```bash POST /v1/dataProducts @@ -102,7 +104,7 @@ curl -X POST "{base_url}/api/v1/dataProducts" \ -H "Content-Type: application/json" \ -d '{ "name": "CustomerInsights", - "domain": "Marketing", + "domains": ["Marketing"], "description": "Curated customer analytics data product", "owners": [], "experts": [] @@ -115,20 +117,22 @@ curl -X POST "{base_url}/api/v1/dataProducts" \ { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Curated customer analytics data product", "version": 0.1, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -153,7 +157,7 @@ Returns the created data product object with all specified properties and system - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. @@ -164,8 +168,8 @@ Returns the created data product object with all specified properties and system Description of the data product in Markdown format. - - Reference to the parent domain. + + References to the parent domains. @@ -224,4 +228,4 @@ curl -X PUT "{base_url}/api/v1/dataProducts" \ | `400` | `BAD_REQUEST` | Invalid request body or missing required fields | | `401` | `UNAUTHORIZED` | Invalid or missing authentication token | | `403` | `FORBIDDEN` | User lacks permission to create data products | -| `409` | `ENTITY_ALREADY_EXISTS` | Data product with same name already exists in domain (POST only) | +| `409` | `ENTITY_ALREADY_EXISTS` | Data product with the same name already exists (POST only) | diff --git a/v1.13.x/api-reference/governance/data-products/delete.mdx b/v1.13.x/api-reference/governance/data-products/delete.mdx index e69068056..eb414ec39 100644 --- a/v1.13.x/api-reference/governance/data-products/delete.mdx +++ b/v1.13.x/api-reference/governance/data-products/delete.mdx @@ -1,13 +1,13 @@ --- title: Delete a Data Product -description: Delete a data product by ID or name, with soft/hard delete options +description: Delete a data product by ID or name, permanently sidebarTitle: Delete a Data Product api: DELETE /v1/dataProducts/{id} --- # Delete a Data Product -Delete a data product by ID or fully qualified name. Supports soft delete (default), hard delete, and restore operations. +Delete a data product by ID or fully qualified name. Deleting a data product is permanent. A deleted data product can't be restored. ## Delete by ID @@ -20,7 +20,7 @@ Delete a data product by ID or fully qualified name. Supports soft delete (defau - Permanently delete the data product. If `false`, the data product is soft-deleted and can be restored. + Not needed. A deleted data product is always permanently deleted, with or without this option. ## Delete by Name @@ -28,7 +28,7 @@ Delete a data product by ID or fully qualified name. Supports soft delete (defau Use `DELETE /v1/dataProducts/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the data product (e.g., `Marketing.CustomerInsights`). + Fully qualified name of the data product, for example `CustomerInsights`. @@ -36,15 +36,7 @@ Use `DELETE /v1/dataProducts/name/{fqn}` to delete by fully qualified name. - Permanently delete the data product. - - -## Restore a Soft-Deleted Data Product - -Use `PUT /v1/dataProducts/restore` to restore a soft-deleted data product. - - - UUID of the soft-deleted data product to restore. + Not needed. A deleted data product is always permanently deleted, with or without this option. @@ -57,89 +49,53 @@ configure( jwt_token="your-jwt-token" ) -# Soft delete by ID +# Delete by ID DataProducts.delete("b1839f98-f046-5f35-bdef-20f9b3395cb2") -# Hard delete +# Delete by ID with options DataProducts.delete( "b1839f98-f046-5f35-bdef-20f9b3395cb2", hard_delete=True ) # Delete by name -DataProducts.delete_by_name("Marketing.CustomerInsights") - -# Restore a soft-deleted data product -DataProducts.restore("b1839f98-f046-5f35-bdef-20f9b3395cb2") +DataProducts.delete(DataProducts.retrieve_by_name("CustomerInsights").id) ``` ```java DELETE /v1/dataProducts/{id} -import static org.openmetadata.sdk.fluent.DataProducts.*; +import java.util.Map; -// Soft delete -DataProducts.delete("b1839f98-f046-5f35-bdef-20f9b3395cb2").execute(); +// client is an initialized OpenMetadataClient. +var id = "b1839f98-f046-5f35-bdef-20f9b3395cb2"; -// Hard delete -DataProducts.delete("b1839f98-f046-5f35-bdef-20f9b3395cb2") - .hardDelete() - .execute(); - -// Delete by name -DataProducts.deleteByName("Marketing.CustomerInsights").execute(); +// Delete (permanent) +client.dataProducts().delete(id); -// Restore -DataProducts.restore("b1839f98-f046-5f35-bdef-20f9b3395cb2"); +// Delete by name: look up the ID first +var dataProduct = client.dataProducts().getByName("CustomerInsights"); +client.dataProducts().delete(dataProduct.getId().toString()); ``` ```bash DELETE /v1/dataProducts/{id} -# Soft delete by ID +# Delete by ID curl -X DELETE "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2" \ -H "Authorization: Bearer {access_token}" -# Hard delete +# Delete with options curl -X DELETE "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2?hardDelete=true" \ -H "Authorization: Bearer {access_token}" # Delete by name -curl -X DELETE "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ +curl -X DELETE "{base_url}/api/v1/dataProducts/name/CustomerInsights" \ -H "Authorization: Bearer {access_token}" - -# Restore soft-deleted data product -curl -X PUT "{base_url}/api/v1/dataProducts/restore" \ - -H "Authorization: Bearer {access_token}" \ - -H "Content-Type: application/json" \ - -d '{"id": "b1839f98-f046-5f35-bdef-20f9b3395cb2"}' ``` - -```json Response (Soft Delete) -{ - "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", - "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", - "description": "Curated customer analytics data product", - "version": 0.2, - "updatedAt": 1769984330261, - "updatedBy": "admin", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing" - }, - "deleted": true, - "owners": [], - "experts": [] -} -``` - - --- ## Returns -Soft delete returns the data product object with `deleted: true`. Hard delete returns no content (204). Restore returns the restored data product object. +Returns `200` with no content. The data product is permanently deleted and can't be restored. --- diff --git a/v1.13.x/api-reference/governance/data-products/list.mdx b/v1.13.x/api-reference/governance/data-products/list.mdx index e0cb69de1..bc60c4adb 100644 --- a/v1.13.x/api-reference/governance/data-products/list.mdx +++ b/v1.13.x/api-reference/governance/data-products/list.mdx @@ -28,7 +28,7 @@ List all data products with optional filtering and pagination. - Comma-separated list of fields to include: `owners`, `domain`, `experts`, `assets`. See [Supported Fields](#supported-fields) below. + Comma-separated list of fields to include: `owners`, `domains`, `experts`, `assets`. See [Supported Fields](#supported-fields) below. @@ -47,44 +47,46 @@ configure( # List first page products = DataProducts.list(limit=50) -for dp in products.data: - print(f"{dp.fullyQualifiedName}") +for dp in products.entities: + print(f"{dp.fullyQualifiedName.root}") # List all with auto-pagination for dp in DataProducts.list_all(): - print(f"{dp.fullyQualifiedName}") + print(f"{dp.fullyQualifiedName.root}") # Filter by domain with fields products = DataProducts.list( - domain="Marketing", - fields=["owners", "domain", "experts", "assets"], + filters={"domain": "Marketing"}, + fields=["owners", "domains", "experts", "assets"], limit=50 ) -for dp in products.data: - print(f"{dp.fullyQualifiedName}") +for dp in products.entities: + print(f"{dp.fullyQualifiedName.root}") if dp.owners: - print(f" Owners: {[o.name for o in dp.owners]}") + print(f" Owners: {[o.name for o in dp.owners.root]}") ``` ```java GET /v1/dataProducts -import static org.openmetadata.sdk.fluent.DataProducts.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = DataProducts.list() - .limit(50) - .execute(); - -for (var dp : result.getData()) { - System.out.println(dp.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.dataProducts().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by domain with fields -var result = DataProducts.list() - .domain("Marketing") - .fields("owners", "domain", "experts", "assets") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("domain", "Marketing") + .setFields("owners,domains,experts,assets") + .setLimit(50); +var filteredPage = client.dataProducts().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/dataProducts @@ -93,7 +95,7 @@ curl "{base_url}/api/v1/dataProducts?limit=50" \ -H "Authorization: Bearer {access_token}" # Filter by domain -curl "{base_url}/api/v1/dataProducts?domain=Marketing&fields=owners,domain,experts,assets&limit=50" \ +curl "{base_url}/api/v1/dataProducts?domain=Marketing&fields=owners,domains,experts,assets&limit=50" \ -H "Authorization: Bearer {access_token}" ``` @@ -105,20 +107,22 @@ curl "{base_url}/api/v1/dataProducts?domain=Marketing&fields=owners,domain,exper { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Curated customer analytics data product", "version": 0.1, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -153,11 +157,11 @@ Returns a paginated list of data product objects. By default, only basic fields - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. - - Parent domain reference. Only included when `fields` contains `domain`. + + Parent domain references. Only included when `fields` contains `domains`. @@ -199,7 +203,7 @@ Returns a paginated list of data product objects. By default, only basic fields | Field | Description | |-------|-------------| | `owners` | Owner references (users and teams) | -| `domain` | Parent domain reference | +| `domains` | Parent domain references | | `experts` | Subject matter expert references | | `assets` | Associated data assets | diff --git a/v1.13.x/api-reference/governance/data-products/ports-assets.mdx b/v1.13.x/api-reference/governance/data-products/ports-assets.mdx index b809ceab6..c3f155b98 100644 --- a/v1.13.x/api-reference/governance/data-products/ports-assets.mdx +++ b/v1.13.x/api-reference/governance/data-products/ports-assets.mdx @@ -14,7 +14,7 @@ Manage the input ports, output ports, and associated assets of a data product. T Use `PUT /v1/dataProducts/{fqn}/assets/add` to add assets to a data product. - Fully qualified name of the data product, such as `Marketing.CustomerInsights`. + Fully qualified name of the data product, such as `CustomerInsights`. @@ -26,7 +26,7 @@ Use `PUT /v1/dataProducts/{fqn}/assets/add` to add assets to a data product. - Type of asset entity (e.g., `table`, `topic`, `dashboard`, `pipeline`). + Type of asset entity, for example `table`, `topic`, `dashboard`, `pipeline`. @@ -36,7 +36,7 @@ Use `PUT /v1/dataProducts/{fqn}/assets/add` to add assets to a data product. Use `PUT /v1/dataProducts/{fqn}/assets/remove` to remove assets from a data product. - Fully qualified name of the data product, such as `Marketing.CustomerInsights`. + Fully qualified name of the data product, such as `CustomerInsights`. @@ -48,7 +48,7 @@ Use `PUT /v1/dataProducts/{fqn}/assets/remove` to remove assets from a data prod - Type of asset entity (e.g., `table`, `topic`, `dashboard`, `pipeline`). + Type of asset entity, for example `table`, `topic`, `dashboard`, `pipeline`. @@ -64,68 +64,82 @@ configure( jwt_token="your-jwt-token" ) -# Identify the data product by its fully qualified name, and each asset by its UUID. +# Identify the data product by its name, which is also its fully qualified name, and each asset by its UUID. # Add input ports DataProducts.add_input_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-1", type="table")] ) # Remove input ports DataProducts.remove_input_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-1", type="table")] ) # Add output ports DataProducts.add_output_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="dashboard-uuid-1", type="dashboard")] ) # Remove output ports DataProducts.remove_output_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="dashboard-uuid-1", type="dashboard")] ) # Add assets DataProducts.add_assets( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-2", type="table")] ) # Remove assets DataProducts.remove_assets( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-2", type="table")] ) ``` ```java PUT /v1/dataProducts/{fqn}/assets/add -import static org.openmetadata.sdk.fluent.DataProducts.*; +import java.util.List; +import java.util.UUID; +import org.openmetadata.schema.type.EntityReference; +import org.openmetadata.schema.type.api.BulkAssets; -// Identify the data product by its fully qualified name, and each asset by its UUID. +// client is an initialized OpenMetadataClient. +var dataProduct = "CustomerInsights"; + +var tables = new BulkAssets().withAssets(List.of( + new EntityReference() + .withId(UUID.fromString("5b3d9f0e-1c7a-4d2e-9a61-3f8e2b7c4d10")) + .withType("table"))); + +// Identify the data product by its name, which is also its fully qualified name, and each asset by its UUID. // Add assets -DataProducts.addAssets( - "Marketing.CustomerInsights", - List.of(new EntityReference("table-uuid-1", "table")) -); +var added = client.dataProducts().bulkAddAssets(dataProduct, tables); +System.out.println(added.getStatus()); // Remove assets -DataProducts.removeAssets( - "Marketing.CustomerInsights", - List.of(new EntityReference("table-uuid-1", "table")) -); +var removed = client.dataProducts().bulkRemoveAssets(dataProduct, tables); + +// Add and remove input ports +client.dataProducts().bulkAddInputPorts(dataProduct, tables); +client.dataProducts().bulkRemoveInputPorts(dataProduct, tables); + +// Add and remove output ports +client.dataProducts().bulkAddOutputPorts(dataProduct, tables); +client.dataProducts().bulkRemoveOutputPorts(dataProduct, tables); ``` ```bash PUT /v1/dataProducts/{fqn}/assets/add # The path identifier is the data product's fully qualified name. URL-encode it if it contains spaces. # Add assets -curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/add" \ +curl -X PUT "{base_url}/api/v1/dataProducts/CustomerInsights/assets/add" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -136,7 +150,7 @@ curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/ad }' # Remove assets -curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/remove" \ +curl -X PUT "{base_url}/api/v1/dataProducts/CustomerInsights/assets/remove" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -152,19 +166,21 @@ curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/re { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "description": "Curated customer analytics data product", "version": 0.3, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] diff --git a/v1.13.x/api-reference/governance/data-products/retrieve.mdx b/v1.13.x/api-reference/governance/data-products/retrieve.mdx index b08cd3a49..ec3da59a5 100644 --- a/v1.13.x/api-reference/governance/data-products/retrieve.mdx +++ b/v1.13.x/api-reference/governance/data-products/retrieve.mdx @@ -16,7 +16,7 @@ Get a single data product by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,domain,experts,assets`). + Comma-separated list of fields to include, for example `owners,domains,experts,assets`. @@ -28,11 +28,11 @@ Get a single data product by its unique ID or fully qualified name. Use `GET /v1/dataProducts/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the data product (e.g., `Marketing.CustomerInsights`). + Fully qualified name of the data product, for example `CustomerInsights`. - Comma-separated list of fields to include: `owners`, `domain`, `experts`, `assets`. + Comma-separated list of fields to include: `owners`, `domains`, `experts`, `assets`. @@ -51,44 +51,40 @@ configure( # Get by ID dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2") -print(f"{dp.fullyQualifiedName}: {dp.description}") +print(f"{dp.fullyQualifiedName.root}: {getattr(dp.description, 'root', dp.description)}") # Get by ID with fields dp = DataProducts.retrieve( "b1839f98-f046-5f35-bdef-20f9b3395cb2", - fields=["owners", "domain", "experts", "assets"] + fields=["owners", "domains", "experts", "assets"] ) # Get by fully qualified name -dp = DataProducts.retrieve_by_name("Marketing.CustomerInsights") +dp = DataProducts.retrieve_by_name("CustomerInsights") # Get by name with fields dp = DataProducts.retrieve_by_name( - "Marketing.CustomerInsights", - fields=["owners", "domain", "experts", "assets"] + "CustomerInsights", + fields=["owners", "domains", "experts", "assets"] ) ``` ```java GET /v1/dataProducts/{id} -import static org.openmetadata.sdk.fluent.DataProducts.*; - -// Get by ID -var dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2"); +// client is an initialized OpenMetadataClient. +var dataProduct = client.dataProducts().get("b1839f98-f046-5f35-bdef-20f9b3395cb2"); // Get by ID with fields -var dp = DataProducts.retrieve( +var dataProductWithFields = client.dataProducts().get( "b1839f98-f046-5f35-bdef-20f9b3395cb2", - "owners,domain,experts,assets" -); + "owners,domains,experts,assets"); // Get by fully qualified name -var dp = DataProducts.retrieveByName("Marketing.CustomerInsights"); +var dataProductByName = client.dataProducts().getByName("CustomerInsights"); // Get by name with fields -var dp = DataProducts.retrieveByName( - "Marketing.CustomerInsights", - "owners,domain,experts,assets" -); +var dataProductByNameWithFields = client.dataProducts().getByName( + "CustomerInsights", + "owners,domains,experts,assets"); ``` ```bash GET /v1/dataProducts/{id} @@ -97,15 +93,15 @@ curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2" \ -H "Authorization: Bearer {access_token}" # Get by ID with fields -curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2?fields=owners,domain,experts,assets" \ +curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2?fields=owners,domains,experts,assets" \ -H "Authorization: Bearer {access_token}" # Get by fully qualified name -curl "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ +curl "{base_url}/api/v1/dataProducts/name/CustomerInsights" \ -H "Authorization: Bearer {access_token}" # Get by name with fields -curl "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights?fields=owners,domain,experts,assets" \ +curl "{base_url}/api/v1/dataProducts/name/CustomerInsights?fields=owners,domains,experts,assets" \ -H "Authorization: Bearer {access_token}" ``` @@ -115,20 +111,22 @@ curl "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights?fields=owne { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Curated customer analytics data product", "version": 0.1, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -153,7 +151,7 @@ Returns a data product object with all requested fields populated. - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. @@ -164,8 +162,8 @@ Returns a data product object with all requested fields populated. Description of the data product in Markdown format. - - Reference to the parent domain. + + References to the parent domains. diff --git a/v1.13.x/api-reference/governance/data-products/update.mdx b/v1.13.x/api-reference/governance/data-products/update.mdx index dc585f0ad..3b1f66389 100644 --- a/v1.13.x/api-reference/governance/data-products/update.mdx +++ b/v1.13.x/api-reference/governance/data-products/update.mdx @@ -20,7 +20,7 @@ Update a data product's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/dataProducts/name/{fqn}` to update by fully qualified name. - Fully qualified name of the data product (e.g., `Marketing.CustomerInsights`). + Fully qualified name of the data product, for example `CustomerInsights`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -78,16 +78,16 @@ dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2") dp.description = "Updated: Curated customer analytics with enriched profiles" updated = DataProducts.update(dp) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dataProducts/{id} -import static org.openmetadata.sdk.fluent.DataProducts.*; +// client is an initialized OpenMetadataClient. +var dataProductId = "b1839f98-f046-5f35-bdef-20f9b3395cb2"; +var dataProduct = client.dataProducts().get(dataProductId); +dataProduct.setDescription("Updated: Curated customer analytics with enriched profiles"); -// Retrieve, modify, and update -var dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2"); -dp.setDescription("Updated: Curated customer analytics with enriched profiles"); -var updated = DataProducts.update(dp); +var updated = client.dataProducts().update(dataProductId, dataProduct); ``` ```bash PATCH /v1/dataProducts/{id} @@ -100,7 +100,7 @@ curl -X PATCH "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395c ]' # Update by name -curl -X PATCH "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ +curl -X PATCH "{base_url}/api/v1/dataProducts/name/CustomerInsights" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json-patch+json" \ -d '[ @@ -114,20 +114,22 @@ curl -X PATCH "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Updated: Curated customer analytics with enriched profiles", "version": 0.2, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -152,7 +154,7 @@ Returns the updated data product object with the new version number. - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. diff --git a/v1.13.x/api-reference/governance/data-products/versions.mdx b/v1.13.x/api-reference/governance/data-products/versions.mdx index 7030bc159..e43febe9a 100644 --- a/v1.13.x/api-reference/governance/data-products/versions.mdx +++ b/v1.13.x/api-reference/governance/data-products/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dataProducts/{id}/versions/{version}` to retrieve a specific versio - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dataProducts/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import DataProducts @@ -40,31 +42,29 @@ configure( # List all versions versions = DataProducts.get_versions("b1839f98-f046-5f35-bdef-20f9b3395cb2") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version dp_v1 = DataProducts.get_specific_version( "b1839f98-f046-5f35-bdef-20f9b3395cb2", "0.1" ) -print(f"Original description: {dp_v1.description}") +print(f"Original description: {getattr(dp_v1.description, 'root', dp_v1.description)}") ``` ```java GET /v1/dataProducts/{id}/versions -import static org.openmetadata.sdk.fluent.DataProducts.*; +// client is an initialized OpenMetadataClient. +var id = "b1839f98-f046-5f35-bdef-20f9b3395cb2"; // List all versions -var history = DataProducts.getVersions("b1839f98-f046-5f35-bdef-20f9b3395cb2"); - +var history = client.dataProducts().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = DataProducts.getSpecificVersion( - "b1839f98-f046-5f35-bdef-20f9b3395cb2", - 0.1 -); +var v1 = client.dataProducts().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` @@ -84,8 +84,8 @@ curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2/versio { "entityType": "dataProduct", "versions": [ - "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"Marketing.CustomerInsights\",\"version\":0.2,\"description\":\"Updated description\"}", - "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"Marketing.CustomerInsights\",\"version\":0.1,\"description\":\"Curated customer analytics data product\"}" + "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"CustomerInsights\",\"version\":0.2,\"description\":\"Updated description\"}", + "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"CustomerInsights\",\"version\":0.1,\"description\":\"Curated customer analytics data product\"}" ] } ``` diff --git a/v1.13.x/api-reference/governance/domains/create.mdx b/v1.13.x/api-reference/governance/domains/create.mdx index f728e4c2f..7cb7f51dc 100644 --- a/v1.13.x/api-reference/governance/domains/create.mdx +++ b/v1.13.x/api-reference/governance/domains/create.mdx @@ -28,7 +28,7 @@ Create a new domain for organizing data assets by business area. - Fully qualified name of the parent domain for creating nested domains (e.g., `Engineering`). + Fully qualified name of the parent domain for creating nested domains, for example `Engineering`. @@ -40,7 +40,7 @@ Create a new domain for organizing data assets by business area. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -86,19 +86,20 @@ request = CreateDomainRequest( ) domain = Domains.create(request) -print(f"Created: {domain.fullyQualifiedName}") +print(f"Created: {domain.fullyQualifiedName.root}") ``` ```java POST /v1/domains -import static org.openmetadata.sdk.fluent.Domains.*; - -// Create using builder pattern -var domain = Domains.builder() - .name("TestDomain") - .displayName("Test Domain") - .domainType("Aggregate") - .description("Lorem ipsum...") - .create(); +import org.openmetadata.schema.api.domains.CreateDomain; + +// client is an initialized OpenMetadataClient. +var request = new CreateDomain() + .withName("TestDomain") + .withDisplayName("Test Domain") + .withDomainType(CreateDomain.DomainType.AGGREGATE) + .withDescription("Lorem ipsum..."); + +var domain = client.domains().create(request); ``` ```bash POST /v1/domains @@ -151,7 +152,7 @@ Returns the created domain object with all specified properties and system-gener - Fully qualified name (e.g., `TestDomain` or `parent.child`). + Fully qualified name, for example `TestDomain` or `parent.child`. @@ -175,7 +176,7 @@ Returns the created domain object with all specified properties and system-gener - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. diff --git a/v1.13.x/api-reference/governance/domains/delete.mdx b/v1.13.x/api-reference/governance/domains/delete.mdx index 34f12b830..0a57d3099 100644 --- a/v1.13.x/api-reference/governance/domains/delete.mdx +++ b/v1.13.x/api-reference/governance/domains/delete.mdx @@ -1,13 +1,13 @@ --- title: Delete a Domain -description: Delete a domain by ID or name, with soft/hard delete options +description: Delete a domain by ID or name, permanently sidebarTitle: Delete a Domain api: DELETE /v1/domains/{id} --- # Delete a Domain -Delete a domain by ID or fully qualified name. Supports soft delete (default), hard delete, and restore operations. +Delete a domain by ID or fully qualified name. Deleting a domain is permanent. A deleted domain can't be restored. ## Delete by ID @@ -20,7 +20,7 @@ Delete a domain by ID or fully qualified name. Supports soft delete (default), h - Permanently delete the domain. If `false`, the domain is soft-deleted and can be restored. + Not needed. A deleted domain is always permanently deleted, with or without this option. ## Delete by Name @@ -28,7 +28,7 @@ Delete a domain by ID or fully qualified name. Supports soft delete (default), h Use `DELETE /v1/domains/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the domain (e.g., `TestDomain`). + Fully qualified name of the domain, for example `TestDomain`. @@ -36,15 +36,7 @@ Use `DELETE /v1/domains/name/{fqn}` to delete by fully qualified name. - Permanently delete the domain. - - -## Restore a Soft-Deleted Domain - -Use `PUT /v1/domains/restore` to restore a soft-deleted domain. - - - UUID of the soft-deleted domain to restore. + Not needed. A deleted domain is always permanently deleted, with or without this option. @@ -57,90 +49,59 @@ configure( jwt_token="your-jwt-token" ) -# Soft delete by ID +# Delete by ID Domains.delete("a0729e98-e946-4e25-acde-10e8a2294ba1") -# Hard delete +# Delete by ID with options Domains.delete( "a0729e98-e946-4e25-acde-10e8a2294ba1", hard_delete=True ) # Delete by name -Domains.delete_by_name("TestDomain") +Domains.delete(Domains.retrieve_by_name("TestDomain").id) # Delete by name with options -Domains.delete_by_name( - "TestDomain", +Domains.delete( + Domains.retrieve_by_name("TestDomain").id, hard_delete=True ) - -# Restore a soft-deleted domain -Domains.restore("a0729e98-e946-4e25-acde-10e8a2294ba1") ``` ```java DELETE /v1/domains/{id} -import static org.openmetadata.sdk.fluent.Domains.*; +import java.util.Map; -// Soft delete -Domains.delete("a0729e98-e946-4e25-acde-10e8a2294ba1").execute(); +// client is an initialized OpenMetadataClient. +var id = "a0729e98-e946-4e25-acde-10e8a2294ba1"; -// Hard delete -Domains.delete("a0729e98-e946-4e25-acde-10e8a2294ba1") - .hardDelete() - .execute(); - -// Delete by name -Domains.deleteByName("TestDomain").execute(); +// Delete (permanent) +client.domains().delete(id); -// Restore -Domains.restore("a0729e98-e946-4e25-acde-10e8a2294ba1"); +// Delete by name: look up the ID first +var domain = client.domains().getByName("TestDomain"); +client.domains().delete(domain.getId().toString()); ``` ```bash DELETE /v1/domains/{id} -# Soft delete by ID +# Delete by ID curl -X DELETE "{base_url}/api/v1/domains/a0729e98-e946-4e25-acde-10e8a2294ba1" \ -H "Authorization: Bearer {access_token}" -# Hard delete +# Delete with options curl -X DELETE "{base_url}/api/v1/domains/a0729e98-e946-4e25-acde-10e8a2294ba1?hardDelete=true" \ -H "Authorization: Bearer {access_token}" # Delete by name curl -X DELETE "{base_url}/api/v1/domains/name/TestDomain" \ -H "Authorization: Bearer {access_token}" - -# Restore soft-deleted domain -curl -X PUT "{base_url}/api/v1/domains/restore" \ - -H "Authorization: Bearer {access_token}" \ - -H "Content-Type: application/json" \ - -d '{"id": "a0729e98-e946-4e25-acde-10e8a2294ba1"}' ``` - -```json Response (Soft Delete) -{ - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "domainType": "Aggregate", - "name": "TestDomain", - "fullyQualifiedName": "TestDomain", - "description": "Lorem ipsum...", - "version": 0.2, - "updatedAt": 1769984330261, - "updatedBy": "admin", - "deleted": true, - "owners": [], - "children": [] -} -``` - - --- ## Returns -Soft delete returns the domain object with `deleted: true`. Hard delete returns no content (204). Restore returns the restored domain object. +Returns `200` with no content. The domain is permanently deleted and can't be restored. --- diff --git a/v1.13.x/api-reference/governance/domains/list.mdx b/v1.13.x/api-reference/governance/domains/list.mdx index 6aa66ea17..19d2c1447 100644 --- a/v1.13.x/api-reference/governance/domains/list.mdx +++ b/v1.13.x/api-reference/governance/domains/list.mdx @@ -43,12 +43,12 @@ configure( # List first page domains = Domains.list(limit=50) -for d in domains.data: - print(f"{d.fullyQualifiedName} ({d.domainType})") +for d in domains.entities: + print(f"{d.fullyQualifiedName.root} ({d.domainType})") # List all with auto-pagination for d in Domains.list_all(): - print(f"{d.fullyQualifiedName}") + print(f"{d.fullyQualifiedName.root}") # With fields domains = Domains.list( @@ -56,32 +56,30 @@ domains = Domains.list( limit=50 ) -for d in domains.data: - print(f"{d.fullyQualifiedName}") +for d in domains.entities: + print(f"{d.fullyQualifiedName.root}") if d.owners: - print(f" Owners: {[o.name for o in d.owners]}") + print(f" Owners: {[o.name for o in d.owners.root]}") ``` ```java GET /v1/domains -import static org.openmetadata.sdk.fluent.Domains.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Domains.list() - .limit(50) - .execute(); - -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.domains().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // With fields -var result = Domains.list() - .fields("owners", "children", "experts") - .limit(50) - .execute(); - -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +var filtered = new ListParams() + .setFields("owners,children,experts") + .setLimit(50); +var filteredPage = client.domains().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` diff --git a/v1.13.x/api-reference/governance/domains/retrieve.mdx b/v1.13.x/api-reference/governance/domains/retrieve.mdx index 9afb82fe8..2fcbb7281 100644 --- a/v1.13.x/api-reference/governance/domains/retrieve.mdx +++ b/v1.13.x/api-reference/governance/domains/retrieve.mdx @@ -16,7 +16,7 @@ Get a single domain by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,children,experts`). + Comma-separated list of fields to include, for example `owners,children,experts`. @@ -28,7 +28,7 @@ Get a single domain by its unique ID or fully qualified name. Use `GET /v1/domains/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the domain (e.g., `TestDomain` or `Engineering.DataPlatform`). + Fully qualified name of the domain, for example `TestDomain` or `Engineering.DataPlatform`. @@ -51,7 +51,7 @@ configure( # Get by ID domain = Domains.retrieve("a0729e98-e946-4e25-acde-10e8a2294ba1") -print(f"{domain.fullyQualifiedName}: {domain.domainType}") +print(f"{domain.fullyQualifiedName.root}: {domain.domainType}") # Get by ID with fields domain = Domains.retrieve( @@ -70,22 +70,21 @@ domain = Domains.retrieve_by_name( ``` ```java GET /v1/domains/{id} -import static org.openmetadata.sdk.fluent.Domains.*; - -// Get by ID -var domain = Domains.retrieve("a0729e98-e946-4e25-acde-10e8a2294ba1"); +// client is an initialized OpenMetadataClient. +var domain = client.domains().get("a0729e98-e946-4e25-acde-10e8a2294ba1"); // Get by ID with fields -var domain = Domains.retrieve( +var domainWithFields = client.domains().get( "a0729e98-e946-4e25-acde-10e8a2294ba1", - "owners,children,experts" -); + "owners,children,experts"); // Get by fully qualified name -var domain = Domains.retrieveByName("TestDomain"); +var domainByName = client.domains().getByName("TestDomain"); // Get by name with fields -var domain = Domains.retrieveByName("TestDomain", "owners,children,experts"); +var domainByNameWithFields = client.domains().getByName( + "TestDomain", + "owners,children,experts"); ``` ```bash GET /v1/domains/{id} diff --git a/v1.13.x/api-reference/governance/domains/update.mdx b/v1.13.x/api-reference/governance/domains/update.mdx index 523e20d99..5ceb715d9 100644 --- a/v1.13.x/api-reference/governance/domains/update.mdx +++ b/v1.13.x/api-reference/governance/domains/update.mdx @@ -20,7 +20,7 @@ Update a domain's properties using JSON Merge Patch. You can update by ID or by Use `PATCH /v1/domains/name/{fqn}` to update by fully qualified name. - Fully qualified name of the domain (e.g., `TestDomain`). + Fully qualified name of the domain, for example `TestDomain`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -83,16 +83,16 @@ domain.description = "Updated domain description for business analytics" domain.domainType = "Consumer-aligned" updated = Domains.update(domain) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/domains/{id} -import static org.openmetadata.sdk.fluent.Domains.*; - -// Retrieve, modify, and update -var domain = Domains.retrieve("a0729e98-e946-4e25-acde-10e8a2294ba1"); +// client is an initialized OpenMetadataClient. +var domainId = "a0729e98-e946-4e25-acde-10e8a2294ba1"; +var domain = client.domains().get(domainId); domain.setDescription("Updated domain description for business analytics"); -var updated = Domains.update(domain); + +var updated = client.domains().update(domainId, domain); ``` ```bash PATCH /v1/domains/{id} diff --git a/v1.13.x/api-reference/governance/domains/versions.mdx b/v1.13.x/api-reference/governance/domains/versions.mdx index 9d30b534f..ccd59ec1c 100644 --- a/v1.13.x/api-reference/governance/domains/versions.mdx +++ b/v1.13.x/api-reference/governance/domains/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/domains/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/domains/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Domains @@ -40,31 +42,29 @@ configure( # List all versions versions = Domains.get_versions("a0729e98-e946-4e25-acde-10e8a2294ba1") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version domain_v1 = Domains.get_specific_version( "a0729e98-e946-4e25-acde-10e8a2294ba1", "0.1" ) -print(f"Original description: {domain_v1.description}") +print(f"Original description: {getattr(domain_v1.description, 'root', domain_v1.description)}") ``` ```java GET /v1/domains/{id}/versions -import static org.openmetadata.sdk.fluent.Domains.*; +// client is an initialized OpenMetadataClient. +var id = "a0729e98-e946-4e25-acde-10e8a2294ba1"; // List all versions -var history = Domains.getVersions("a0729e98-e946-4e25-acde-10e8a2294ba1"); - +var history = client.domains().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Domains.getSpecificVersion( - "a0729e98-e946-4e25-acde-10e8a2294ba1", - 0.1 -); +var v1 = client.domains().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/governance/glossaries/create.mdx b/v1.13.x/api-reference/governance/glossaries/create.mdx index fb0b061b0..11a8d93cc 100644 --- a/v1.13.x/api-reference/governance/glossaries/create.mdx +++ b/v1.13.x/api-reference/governance/glossaries/create.mdx @@ -32,7 +32,7 @@ Create a new glossary for organizing business terminology. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Create a new glossary for organizing business terminology. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -104,19 +104,20 @@ request = CreateGlossaryRequest( ) glossary = Glossaries.create(request) -print(f"Created: {glossary.fullyQualifiedName}") +print(f"Created: {glossary.fullyQualifiedName.root}") ``` ```java POST /v1/glossaries -import static org.openmetadata.sdk.fluent.Glossaries.*; - -// Create using builder pattern -var glossary = Glossaries.builder() - .name("BusinessGlossary") - .displayName("Business Glossary") - .description("Standard business terminology for the organization") - .mutuallyExclusive(false) - .create(); +import org.openmetadata.schema.api.data.CreateGlossary; + +// client is an initialized OpenMetadataClient. +var request = new CreateGlossary() + .withName("BusinessGlossary") + .withDisplayName("Business Glossary") + .withDescription("Standard business terminology for the organization") + .withMutuallyExclusive(false); + +var glossary = client.glossaries().create(request); ``` ```bash POST /v1/glossaries diff --git a/v1.13.x/api-reference/governance/glossaries/delete.mdx b/v1.13.x/api-reference/governance/glossaries/delete.mdx index 63176eda3..eea441b08 100644 --- a/v1.13.x/api-reference/governance/glossaries/delete.mdx +++ b/v1.13.x/api-reference/governance/glossaries/delete.mdx @@ -28,7 +28,7 @@ Delete a glossary by ID or fully qualified name. Supports soft delete (default), Use `DELETE /v1/glossaries/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the glossary (e.g., `BusinessGlossary`). + Fully qualified name of the glossary, for example `BusinessGlossary`. @@ -67,28 +67,30 @@ Glossaries.delete( ) # Delete by name -Glossaries.delete_by_name("BusinessGlossary") +Glossaries.delete(Glossaries.retrieve_by_name("BusinessGlossary").id) # Restore a soft-deleted glossary Glossaries.restore("c2940a98-f147-6g46-cdef-31f0c4406dc3") ``` ```java DELETE /v1/glossaries/{id} -import static org.openmetadata.sdk.fluent.Glossaries.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "c2940a98-f147-6g46-cdef-31f0c4406dc3"; // Soft delete -Glossaries.delete("c2940a98-f147-6g46-cdef-31f0c4406dc3").execute(); +client.glossaries().delete(id); -// Hard delete -Glossaries.delete("c2940a98-f147-6g46-cdef-31f0c4406dc3") - .hardDelete() - .execute(); +// Restore +client.glossaries().restore(id); -// Delete by name -Glossaries.deleteByName("BusinessGlossary").execute(); +// Hard delete +client.glossaries().delete(id, Map.of("hardDelete", "true")); -// Restore -Glossaries.restore("c2940a98-f147-6g46-cdef-31f0c4406dc3"); +// Delete by name: look up the ID first +var glossary = client.glossaries().getByName("BusinessGlossary"); +client.glossaries().delete(glossary.getId().toString()); ``` ```bash DELETE /v1/glossaries/{id} diff --git a/v1.13.x/api-reference/governance/glossaries/list.mdx b/v1.13.x/api-reference/governance/glossaries/list.mdx index f22003d70..29fa57f6c 100644 --- a/v1.13.x/api-reference/governance/glossaries/list.mdx +++ b/v1.13.x/api-reference/governance/glossaries/list.mdx @@ -43,12 +43,12 @@ configure( # List first page glossaries = Glossaries.list(limit=50) -for g in glossaries.data: - print(f"{g.fullyQualifiedName}") +for g in glossaries.entities: + print(f"{g.fullyQualifiedName.root}") # List all with auto-pagination for g in Glossaries.list_all(): - print(f"{g.fullyQualifiedName}") + print(f"{g.fullyQualifiedName.root}") # With fields glossaries = Glossaries.list( @@ -56,29 +56,31 @@ glossaries = Glossaries.list( limit=50 ) -for g in glossaries.data: - print(f"{g.fullyQualifiedName}") +for g in glossaries.entities: + print(f"{g.fullyQualifiedName.root}") if g.reviewers: print(f" Reviewers: {[r.name for r in g.reviewers]}") ``` ```java GET /v1/glossaries -import static org.openmetadata.sdk.fluent.Glossaries.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Glossaries.list() - .limit(50) - .execute(); - -for (var g : result.getData()) { - System.out.println(g.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.glossaries().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // With fields -var result = Glossaries.list() - .fields("owners", "tags", "reviewers") - .limit(50) - .execute(); +var filtered = new ListParams() + .setFields("owners,tags,reviewers") + .setLimit(50); +var filteredPage = client.glossaries().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/glossaries diff --git a/v1.13.x/api-reference/governance/glossaries/retrieve.mdx b/v1.13.x/api-reference/governance/glossaries/retrieve.mdx index 363d22fdd..275ed83fa 100644 --- a/v1.13.x/api-reference/governance/glossaries/retrieve.mdx +++ b/v1.13.x/api-reference/governance/glossaries/retrieve.mdx @@ -16,7 +16,7 @@ Get a single glossary by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains,reviewers`). + Comma-separated list of fields to include, for example `owners,tags,domains,reviewers`. @@ -28,7 +28,7 @@ Get a single glossary by its unique ID or fully qualified name. Use `GET /v1/glossaries/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the glossary (e.g., `BusinessGlossary`). + Fully qualified name of the glossary, for example `BusinessGlossary`. @@ -51,7 +51,7 @@ configure( # Get by ID glossary = Glossaries.retrieve("c2940a98-f147-6g46-cdef-31f0c4406dc3") -print(f"{glossary.fullyQualifiedName}: {glossary.description}") +print(f"{glossary.fullyQualifiedName.root}: {getattr(glossary.description, 'root', glossary.description)}") # Get by ID with fields glossary = Glossaries.retrieve( @@ -70,22 +70,21 @@ glossary = Glossaries.retrieve_by_name( ``` ```java GET /v1/glossaries/{id} -import static org.openmetadata.sdk.fluent.Glossaries.*; - -// Get by ID -var glossary = Glossaries.retrieve("c2940a98-f147-6g46-cdef-31f0c4406dc3"); +// client is an initialized OpenMetadataClient. +var glossary = client.glossaries().get("c2940a98-f147-6g46-cdef-31f0c4406dc3"); // Get by ID with fields -var glossary = Glossaries.retrieve( +var glossaryWithFields = client.glossaries().get( "c2940a98-f147-6g46-cdef-31f0c4406dc3", - "owners,tags,reviewers" -); + "owners,tags,reviewers"); // Get by fully qualified name -var glossary = Glossaries.retrieveByName("BusinessGlossary"); +var glossaryByName = client.glossaries().getByName("BusinessGlossary"); // Get by name with fields -var glossary = Glossaries.retrieveByName("BusinessGlossary", "owners,tags,reviewers"); +var glossaryByNameWithFields = client.glossaries().getByName( + "BusinessGlossary", + "owners,tags,reviewers"); ``` ```bash GET /v1/glossaries/{id} diff --git a/v1.13.x/api-reference/governance/glossaries/update.mdx b/v1.13.x/api-reference/governance/glossaries/update.mdx index 8bcb58598..9fb29ea9b 100644 --- a/v1.13.x/api-reference/governance/glossaries/update.mdx +++ b/v1.13.x/api-reference/governance/glossaries/update.mdx @@ -20,7 +20,7 @@ Update a glossary's properties using JSON Merge Patch. You can update by ID or b Use `PATCH /v1/glossaries/name/{fqn}` to update by fully qualified name. - Fully qualified name of the glossary (e.g., `BusinessGlossary`). + Fully qualified name of the glossary, for example `BusinessGlossary`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -76,17 +76,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -105,16 +105,16 @@ glossary.description = "Updated: Comprehensive business terminology dictionary" glossary.mutuallyExclusive = True updated = Glossaries.update(glossary) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/glossaries/{id} -import static org.openmetadata.sdk.fluent.Glossaries.*; - -// Retrieve, modify, and update -var glossary = Glossaries.retrieve("c2940a98-f147-6g46-cdef-31f0c4406dc3"); +// client is an initialized OpenMetadataClient. +var glossaryId = "c2940a98-f147-6g46-cdef-31f0c4406dc3"; +var glossary = client.glossaries().get(glossaryId); glossary.setDescription("Updated: Comprehensive business terminology dictionary"); -var updated = Glossaries.update(glossary); + +var updated = client.glossaries().update(glossaryId, glossary); ``` ```bash PATCH /v1/glossaries/{id} diff --git a/v1.13.x/api-reference/governance/glossaries/versions.mdx b/v1.13.x/api-reference/governance/glossaries/versions.mdx index 979d53ed4..8ee8acd38 100644 --- a/v1.13.x/api-reference/governance/glossaries/versions.mdx +++ b/v1.13.x/api-reference/governance/glossaries/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/glossaries/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/glossaries/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Glossaries @@ -40,31 +42,29 @@ configure( # List all versions versions = Glossaries.get_versions("c2940a98-f147-6g46-cdef-31f0c4406dc3") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version glossary_v1 = Glossaries.get_specific_version( "c2940a98-f147-6g46-cdef-31f0c4406dc3", "0.1" ) -print(f"Original description: {glossary_v1.description}") +print(f"Original description: {getattr(glossary_v1.description, 'root', glossary_v1.description)}") ``` ```java GET /v1/glossaries/{id}/versions -import static org.openmetadata.sdk.fluent.Glossaries.*; +// client is an initialized OpenMetadataClient. +var id = "c2940a98-f147-6g46-cdef-31f0c4406dc3"; // List all versions -var history = Glossaries.getVersions("c2940a98-f147-6g46-cdef-31f0c4406dc3"); - +var history = client.glossaries().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Glossaries.getSpecificVersion( - "c2940a98-f147-6g46-cdef-31f0c4406dc3", - 0.1 -); +var v1 = client.glossaries().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/governance/glossary-terms/create.mdx b/v1.13.x/api-reference/governance/glossary-terms/create.mdx index dc3fc9f08..65e05d992 100644 --- a/v1.13.x/api-reference/governance/glossary-terms/create.mdx +++ b/v1.13.x/api-reference/governance/glossary-terms/create.mdx @@ -16,7 +16,7 @@ Create a new glossary term within a glossary. - Fully qualified name of the parent glossary (e.g., `BusinessGlossary`). + Fully qualified name of the parent glossary, for example `BusinessGlossary`. @@ -28,7 +28,7 @@ Create a new glossary term within a glossary. - Fully qualified name of the parent glossary term for creating nested terms (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the parent glossary term for creating nested terms, for example `BusinessGlossary.Revenue`. @@ -48,7 +48,7 @@ Create a new glossary term within a glossary. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,17 +66,17 @@ Create a new glossary term within a glossary. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -84,7 +84,7 @@ Create a new glossary term within a glossary. - Hex color code (e.g., `#FF5733`). + Hex color code, for example `#FF5733`. @@ -113,20 +113,22 @@ request = CreateGlossaryTermRequest( ) term = GlossaryTerms.create(request) -print(f"Created: {term.fullyQualifiedName}") +print(f"Created: {term.fullyQualifiedName.root}") ``` ```java POST /v1/glossaryTerms -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; - -// Create using builder pattern -var term = GlossaryTerms.builder() - .name("Revenue") - .glossary("BusinessGlossary") - .displayName("Revenue") - .description("Total income generated from business operations") - .synonyms(List.of("Income", "Earnings", "Sales")) - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateGlossaryTerm; + +// client is an initialized OpenMetadataClient. +var request = new CreateGlossaryTerm() + .withName("Revenue") + .withGlossary("BusinessGlossary") + .withDisplayName("Revenue") + .withDescription("Total income generated from business operations") + .withSynonyms(List.of("Income", "Earnings", "Sales")); + +var term = client.glossaryTerms().create(request); ``` ```bash POST /v1/glossaryTerms diff --git a/v1.13.x/api-reference/governance/glossary-terms/delete.mdx b/v1.13.x/api-reference/governance/glossary-terms/delete.mdx index 59cee26b5..885fa95ea 100644 --- a/v1.13.x/api-reference/governance/glossary-terms/delete.mdx +++ b/v1.13.x/api-reference/governance/glossary-terms/delete.mdx @@ -28,7 +28,7 @@ Delete a glossary term by ID or fully qualified name. Supports soft delete (defa Use `DELETE /v1/glossaryTerms/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the glossary term (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the glossary term, for example `BusinessGlossary.Revenue`. @@ -67,28 +67,30 @@ GlossaryTerms.delete( ) # Delete by name -GlossaryTerms.delete_by_name("BusinessGlossary.Revenue") +GlossaryTerms.delete(GlossaryTerms.retrieve_by_name("BusinessGlossary.Revenue").id) # Restore a soft-deleted glossary term GlossaryTerms.restore("d3a50b09-g258-7h57-defg-42g1d5517ed4") ``` ```java DELETE /v1/glossaryTerms/{id} -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "d3a50b09-g258-7h57-defg-42g1d5517ed4"; // Soft delete -GlossaryTerms.delete("d3a50b09-g258-7h57-defg-42g1d5517ed4").execute(); +client.glossaryTerms().delete(id); -// Hard delete -GlossaryTerms.delete("d3a50b09-g258-7h57-defg-42g1d5517ed4") - .hardDelete() - .execute(); +// Restore +client.glossaryTerms().restore(id); -// Delete by name -GlossaryTerms.deleteByName("BusinessGlossary.Revenue").execute(); +// Hard delete +client.glossaryTerms().delete(id, Map.of("hardDelete", "true")); -// Restore -GlossaryTerms.restore("d3a50b09-g258-7h57-defg-42g1d5517ed4"); +// Delete by name: look up the ID first +var term = client.glossaryTerms().getByName("BusinessGlossary.Revenue"); +client.glossaryTerms().delete(term.getId().toString()); ``` ```bash DELETE /v1/glossaryTerms/{id} diff --git a/v1.13.x/api-reference/governance/glossary-terms/list.mdx b/v1.13.x/api-reference/governance/glossary-terms/list.mdx index 17d391973..50ba82cb0 100644 --- a/v1.13.x/api-reference/governance/glossary-terms/list.mdx +++ b/v1.13.x/api-reference/governance/glossary-terms/list.mdx @@ -42,7 +42,7 @@ List all glossary terms with optional filtering and pagination. ```python GET /v1/glossaryTerms from metadata.sdk import configure -from metadata.sdk.entities import GlossaryTerms +from metadata.sdk.entities import Glossaries, GlossaryTerms configure( host="https://your-company.open-metadata.org/api", @@ -51,44 +51,47 @@ configure( # List first page terms = GlossaryTerms.list(limit=50) -for t in terms.data: - print(f"{t.fullyQualifiedName}") +for t in terms.entities: + print(f"{t.fullyQualifiedName.root}") # List all with auto-pagination for t in GlossaryTerms.list_all(): - print(f"{t.fullyQualifiedName}") + print(f"{t.fullyQualifiedName.root}") # Filter by glossary with fields +glossary = Glossaries.retrieve_by_name("BusinessGlossary") terms = GlossaryTerms.list( - glossary="c2940a98-f147-4a46-8def-31f0c4406dc3", # glossary ID (UUID) + filters={"glossary": str(glossary.id.root)}, fields=["owners", "tags", "relatedTerms", "children"], limit=50 ) -for t in terms.data: - print(f"{t.fullyQualifiedName}") +for t in terms.entities: + print(f"{t.fullyQualifiedName.root}") if t.synonyms: print(f" Synonyms: {t.synonyms}") ``` ```java GET /v1/glossaryTerms -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = GlossaryTerms.list() - .limit(50) - .execute(); - -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.glossaryTerms().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by glossary with fields -var result = GlossaryTerms.list() - .glossary("c2940a98-f147-4a46-8def-31f0c4406dc3") - .fields("owners", "tags", "relatedTerms", "children") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("glossary", "c2940a98-f147-4a46-8def-31f0c4406dc3") + .setFields("owners,tags,relatedTerms,children") + .setLimit(50); +var filteredPage = client.glossaryTerms().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/glossaryTerms diff --git a/v1.13.x/api-reference/governance/glossary-terms/retrieve.mdx b/v1.13.x/api-reference/governance/glossary-terms/retrieve.mdx index 0bdf84ae2..d55d668ba 100644 --- a/v1.13.x/api-reference/governance/glossary-terms/retrieve.mdx +++ b/v1.13.x/api-reference/governance/glossary-terms/retrieve.mdx @@ -16,7 +16,7 @@ Get a single glossary term by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains,relatedTerms,reviewers,children`). + Comma-separated list of fields to include, for example `owners,tags,domains,relatedTerms,reviewers,children`. @@ -28,7 +28,7 @@ Get a single glossary term by its unique ID or fully qualified name. Use `GET /v1/glossaryTerms/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the glossary term (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the glossary term, for example `BusinessGlossary.Revenue`. @@ -51,7 +51,7 @@ configure( # Get by ID term = GlossaryTerms.retrieve("d3a50b09-g258-7h57-defg-42g1d5517ed4") -print(f"{term.fullyQualifiedName}: {term.description}") +print(f"{term.fullyQualifiedName.root}: {getattr(term.description, 'root', term.description)}") # Get by ID with fields term = GlossaryTerms.retrieve( @@ -70,25 +70,21 @@ term = GlossaryTerms.retrieve_by_name( ``` ```java GET /v1/glossaryTerms/{id} -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; - -// Get by ID -var term = GlossaryTerms.retrieve("d3a50b09-g258-7h57-defg-42g1d5517ed4"); +// client is an initialized OpenMetadataClient. +var term = client.glossaryTerms().get("d3a50b09-g258-7h57-defg-42g1d5517ed4"); // Get by ID with fields -var term = GlossaryTerms.retrieve( +var termWithFields = client.glossaryTerms().get( "d3a50b09-g258-7h57-defg-42g1d5517ed4", - "owners,tags,relatedTerms,children" -); + "owners,tags,relatedTerms,children"); // Get by fully qualified name -var term = GlossaryTerms.retrieveByName("BusinessGlossary.Revenue"); +var termByName = client.glossaryTerms().getByName("BusinessGlossary.Revenue"); // Get by name with fields -var term = GlossaryTerms.retrieveByName( +var termByNameWithFields = client.glossaryTerms().getByName( "BusinessGlossary.Revenue", - "owners,tags,relatedTerms,children" -); + "owners,tags,relatedTerms,children"); ``` ```bash GET /v1/glossaryTerms/{id} diff --git a/v1.13.x/api-reference/governance/glossary-terms/update.mdx b/v1.13.x/api-reference/governance/glossary-terms/update.mdx index f581f5509..9992e9a93 100644 --- a/v1.13.x/api-reference/governance/glossary-terms/update.mdx +++ b/v1.13.x/api-reference/governance/glossary-terms/update.mdx @@ -20,7 +20,7 @@ Update a glossary term's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/glossaryTerms/name/{fqn}` to update by fully qualified name. - Fully qualified name of the glossary term (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the glossary term, for example `BusinessGlossary.Revenue`. ## Body Parameters @@ -52,7 +52,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,11 +66,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -80,7 +80,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Hex color code (e.g., `#FF5733`). + Hex color code, for example `#FF5733`. @@ -89,8 +89,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -109,16 +109,16 @@ term.description = "Updated: Total income from all business operations before de term.synonyms = ["Income", "Earnings", "Sales", "Turnover"] updated = GlossaryTerms.update(term) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/glossaryTerms/{id} -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; - -// Retrieve, modify, and update -var term = GlossaryTerms.retrieve("d3a50b09-g258-7h57-defg-42g1d5517ed4"); +// client is an initialized OpenMetadataClient. +var termId = "d3a50b09-g258-7h57-defg-42g1d5517ed4"; +var term = client.glossaryTerms().get(termId); term.setDescription("Updated: Total income from all business operations before deductions"); -var updated = GlossaryTerms.update(term); + +var updated = client.glossaryTerms().update(termId, term); ``` ```bash PATCH /v1/glossaryTerms/{id} diff --git a/v1.13.x/api-reference/governance/glossary-terms/versions.mdx b/v1.13.x/api-reference/governance/glossary-terms/versions.mdx index b64c53bf9..16998a3d8 100644 --- a/v1.13.x/api-reference/governance/glossary-terms/versions.mdx +++ b/v1.13.x/api-reference/governance/glossary-terms/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/glossaryTerms/{id}/versions/{version}` to retrieve a specific versi - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/glossaryTerms/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import GlossaryTerms @@ -40,31 +42,29 @@ configure( # List all versions versions = GlossaryTerms.get_versions("d3a50b09-g258-7h57-defg-42g1d5517ed4") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version term_v1 = GlossaryTerms.get_specific_version( "d3a50b09-g258-7h57-defg-42g1d5517ed4", "0.1" ) -print(f"Original description: {term_v1.description}") +print(f"Original description: {getattr(term_v1.description, 'root', term_v1.description)}") ``` ```java GET /v1/glossaryTerms/{id}/versions -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; +// client is an initialized OpenMetadataClient. +var id = "d3a50b09-g258-7h57-defg-42g1d5517ed4"; // List all versions -var history = GlossaryTerms.getVersions("d3a50b09-g258-7h57-defg-42g1d5517ed4"); - +var history = client.glossaryTerms().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = GlossaryTerms.getSpecificVersion( - "d3a50b09-g258-7h57-defg-42g1d5517ed4", - 0.1 -); +var v1 = client.glossaryTerms().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/governance/tags/create.mdx b/v1.13.x/api-reference/governance/tags/create.mdx index 729d1ff42..d6be682af 100644 --- a/v1.13.x/api-reference/governance/tags/create.mdx +++ b/v1.13.x/api-reference/governance/tags/create.mdx @@ -16,7 +16,7 @@ Create a new tag within a classification. - Fully qualified name of the parent classification (e.g., `Certification`). + Fully qualified name of the parent classification, for example `Certification`. @@ -28,7 +28,7 @@ Create a new tag within a classification. - Fully qualified name of the parent tag for creating nested tags (e.g., `PII.Sensitive`). + Fully qualified name of the parent tag for creating nested tags, for example `PII.Sensitive`. @@ -36,7 +36,7 @@ Create a new tag within a classification. - Hex color code (e.g., `#C08320`). + Hex color code, for example `#C08320`. @@ -54,7 +54,7 @@ Create a new tag within a classification. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -86,19 +86,21 @@ request = CreateTagRequest( ) tag = Tags.create(request) -print(f"Created: {tag.fullyQualifiedName}") +print(f"Created: {tag.fullyQualifiedName.root}") ``` ```java POST /v1/tags -import static org.openmetadata.sdk.fluent.Tags.*; - -// Create using builder pattern -var tag = Tags.builder() - .name("Bronze") - .classification("Certification") - .description("Bronze certified Data Asset.") - .style(Map.of("color", "#C08320")) - .create(); +import org.openmetadata.schema.api.classification.CreateTag; +import org.openmetadata.schema.entity.type.Style; + +// client is an initialized OpenMetadataClient. +var request = new CreateTag() + .withName("Bronze") + .withClassification("Certification") + .withDescription("Bronze certified Data Asset.") + .withStyle(new Style().withColor("#C08320")); + +var tag = client.tags().create(request); ``` ```bash POST /v1/tags diff --git a/v1.13.x/api-reference/governance/tags/delete.mdx b/v1.13.x/api-reference/governance/tags/delete.mdx index 9bcc64a75..833580aee 100644 --- a/v1.13.x/api-reference/governance/tags/delete.mdx +++ b/v1.13.x/api-reference/governance/tags/delete.mdx @@ -28,7 +28,7 @@ Delete a tag by ID or fully qualified name. Supports soft delete (default), hard Use `DELETE /v1/tags/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the tag (e.g., `Certification.Bronze`). + Fully qualified name of the tag, for example `Certification.Bronze`. @@ -67,28 +67,30 @@ Tags.delete( ) # Delete by name -Tags.delete_by_name("Certification.Bronze") +Tags.delete(Tags.retrieve_by_name("Certification.Bronze").id) # Restore a soft-deleted tag Tags.restore("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") ``` ```java DELETE /v1/tags/{id} -import static org.openmetadata.sdk.fluent.Tags.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "68ec158c-5f5e-4277-8a19-5e9e0cd5294f"; // Soft delete -Tags.delete("68ec158c-5f5e-4277-8a19-5e9e0cd5294f").execute(); +client.tags().delete(id); -// Hard delete -Tags.delete("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") - .hardDelete() - .execute(); +// Restore +client.tags().restore(id); -// Delete by name -Tags.deleteByName("Certification.Bronze").execute(); +// Hard delete +client.tags().delete(id, Map.of("hardDelete", "true")); -// Restore -Tags.restore("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); +// Delete by name: look up the ID first +var tag = client.tags().getByName("Certification.Bronze"); +client.tags().delete(tag.getId().toString()); ``` ```bash DELETE /v1/tags/{id} diff --git a/v1.13.x/api-reference/governance/tags/list.mdx b/v1.13.x/api-reference/governance/tags/list.mdx index dfb16c47e..02efdd34f 100644 --- a/v1.13.x/api-reference/governance/tags/list.mdx +++ b/v1.13.x/api-reference/governance/tags/list.mdx @@ -12,7 +12,7 @@ List all tags with optional filtering and pagination. ## Query Parameters - Filter by parent classification fully qualified name (e.g., `Certification`). + Filter by parent classification fully qualified name, for example `Certification`. @@ -47,44 +47,46 @@ configure( # List first page tags = Tags.list(limit=50) -for t in tags.data: - print(f"{t.fullyQualifiedName}") +for t in tags.entities: + print(f"{t.fullyQualifiedName.root}") # List all with auto-pagination for t in Tags.list_all(): - print(f"{t.fullyQualifiedName}") + print(f"{t.fullyQualifiedName.root}") # Filter by classification tags = Tags.list( - parent="Certification", + filters={"parent": "Certification"}, fields=["owners", "children"], limit=50 ) -for t in tags.data: - print(f"{t.fullyQualifiedName}") +for t in tags.entities: + print(f"{t.fullyQualifiedName.root}") if t.style: - print(f" Color: {t.style.get('color')}") + print(f" Color: {t.style.color}") ``` ```java GET /v1/tags -import static org.openmetadata.sdk.fluent.Tags.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Tags.list() - .limit(50) - .execute(); - -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.tags().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by classification with fields -var result = Tags.list() - .parent("Certification") - .fields("owners", "children") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("parent", "Certification") + .setFields("owners,children") + .setLimit(50); +var filteredPage = client.tags().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/tags diff --git a/v1.13.x/api-reference/governance/tags/retrieve.mdx b/v1.13.x/api-reference/governance/tags/retrieve.mdx index d6a5cf81e..7bcc4709c 100644 --- a/v1.13.x/api-reference/governance/tags/retrieve.mdx +++ b/v1.13.x/api-reference/governance/tags/retrieve.mdx @@ -16,7 +16,7 @@ Get a single tag by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,children`). + Comma-separated list of fields to include, for example `owners,children`. @@ -28,7 +28,7 @@ Get a single tag by its unique ID or fully qualified name. Use `GET /v1/tags/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the tag (e.g., `Certification.Bronze`). + Fully qualified name of the tag, for example `Certification.Bronze`. @@ -51,7 +51,7 @@ configure( # Get by ID tag = Tags.retrieve("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") -print(f"{tag.fullyQualifiedName}: {tag.description}") +print(f"{tag.fullyQualifiedName.root}: {getattr(tag.description, 'root', tag.description)}") # Get by ID with fields tag = Tags.retrieve( @@ -70,22 +70,21 @@ tag = Tags.retrieve_by_name( ``` ```java GET /v1/tags/{id} -import static org.openmetadata.sdk.fluent.Tags.*; - -// Get by ID -var tag = Tags.retrieve("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); +// client is an initialized OpenMetadataClient. +var tag = client.tags().get("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); // Get by ID with fields -var tag = Tags.retrieve( +var tagWithFields = client.tags().get( "68ec158c-5f5e-4277-8a19-5e9e0cd5294f", - "owners,children" -); + "owners,children"); // Get by fully qualified name -var tag = Tags.retrieveByName("Certification.Bronze"); +var tagByName = client.tags().getByName("Certification.Bronze"); // Get by name with fields -var tag = Tags.retrieveByName("Certification.Bronze", "owners,children"); +var tagByNameWithFields = client.tags().getByName( + "Certification.Bronze", + "owners,children"); ``` ```bash GET /v1/tags/{id} diff --git a/v1.13.x/api-reference/governance/tags/update.mdx b/v1.13.x/api-reference/governance/tags/update.mdx index 68105a8b8..2a4131dc6 100644 --- a/v1.13.x/api-reference/governance/tags/update.mdx +++ b/v1.13.x/api-reference/governance/tags/update.mdx @@ -20,7 +20,7 @@ Update a tag's properties using JSON Merge Patch. You can update by ID or by ful Use `PATCH /v1/tags/name/{fqn}` to update by fully qualified name. - Fully qualified name of the tag (e.g., `Certification.Bronze`). + Fully qualified name of the tag, for example `Certification.Bronze`. ## Body Parameters @@ -40,7 +40,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Hex color code (e.g., `#C08320`). + Hex color code, for example `#C08320`. @@ -58,7 +58,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -79,16 +79,16 @@ tag.description = "Updated: Bronze level certification for data assets" tag.style = {"color": "#D4A017"} updated = Tags.update(tag) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/tags/{id} -import static org.openmetadata.sdk.fluent.Tags.*; - -// Retrieve, modify, and update -var tag = Tags.retrieve("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); +// client is an initialized OpenMetadataClient. +var tagId = "68ec158c-5f5e-4277-8a19-5e9e0cd5294f"; +var tag = client.tags().get(tagId); tag.setDescription("Updated: Bronze level certification for data assets"); -var updated = Tags.update(tag); + +var updated = client.tags().update(tagId, tag); ``` ```bash PATCH /v1/tags/{id} diff --git a/v1.13.x/api-reference/governance/tags/versions.mdx b/v1.13.x/api-reference/governance/tags/versions.mdx index 3b7fbfaa0..63a5e4474 100644 --- a/v1.13.x/api-reference/governance/tags/versions.mdx +++ b/v1.13.x/api-reference/governance/tags/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/tags/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/tags/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Tags @@ -40,31 +42,29 @@ configure( # List all versions versions = Tags.get_versions("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version tag_v1 = Tags.get_specific_version( "68ec158c-5f5e-4277-8a19-5e9e0cd5294f", "0.1" ) -print(f"Original description: {tag_v1.description}") +print(f"Original description: {getattr(tag_v1.description, 'root', tag_v1.description)}") ``` ```java GET /v1/tags/{id}/versions -import static org.openmetadata.sdk.fluent.Tags.*; +// client is an initialized OpenMetadataClient. +var id = "68ec158c-5f5e-4277-8a19-5e9e0cd5294f"; // List all versions -var history = Tags.getVersions("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); - +var history = client.tags().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Tags.getSpecificVersion( - "68ec158c-5f5e-4277-8a19-5e9e0cd5294f", - 0.1 -); +var v1 = client.tags().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v1.13.x/api-reference/lineage/export.mdx b/v1.13.x/api-reference/lineage/export.mdx index 0c9822e2d..ca38ffdca 100644 --- a/v1.13.x/api-reference/lineage/export.mdx +++ b/v1.13.x/api-reference/lineage/export.mdx @@ -12,7 +12,7 @@ Export the lineage graph for a given entity as a CSV file. Useful for auditing, ## Query Parameters - Fully qualified name of the entity to export lineage for (e.g., `sample_data.ecommerce_db.shopify.dim_customer`). + Fully qualified name of the entity to export lineage for, for example `sample_data.ecommerce_db.shopify.dim_customer`. @@ -29,21 +29,24 @@ Export the lineage graph for a given entity as a CSV file. Useful for auditing, ```python GET /v1/lineage/export -from metadata.sdk import configure, get_client +from urllib.parse import urlencode + +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Export lineage as CSV -response = client.get("/lineage/export", params={ +params = urlencode({ "fqn": "sample_data.ecommerce_db.shopify.dim_customer", "type": "table", "upstreamDepth": 3, "downstreamDepth": 2, }) +response = rest.get(f"/lineage/export?{params}") print(response.text) ``` diff --git a/v1.13.x/api-reference/pagination.mdx b/v1.13.x/api-reference/pagination.mdx index f18f07985..a91fb1419 100644 --- a/v1.13.x/api-reference/pagination.mdx +++ b/v1.13.x/api-reference/pagination.mdx @@ -95,25 +95,23 @@ if first_page.paging.after: ``` ```java Basic Pagination -import org.openmetadata.client.api.TablesApi; -import org.openmetadata.client.model.TableList; +import org.openmetadata.sdk.models.ListParams; -TablesApi tablesApi = client.buildClient(TablesApi.class); +// client is an initialized OpenMetadataClient. // Get first page -TableList firstPage = tablesApi.listTables(null, 20, null, null, null); +var firstPage = client.tables().list(new ListParams().setLimit(20)); System.out.println("Total tables: " + firstPage.getPaging().getTotal()); -for (Table table : firstPage.getData()) { +for (var table : firstPage.getData()) { System.out.println(table.getFullyQualifiedName()); } // Get next page if (firstPage.getPaging().getAfter() != null) { - TableList nextPage = tablesApi.listTables( - null, 20, null, firstPage.getPaging().getAfter(), null - ); - for (Table table : nextPage.getData()) { + var nextPage = client.tables().list( + new ListParams().setLimit(20).setAfter(firstPage.getPaging().getAfter())); + for (var table : nextPage.getData()) { System.out.println(table.getFullyQualifiedName()); } } @@ -171,15 +169,20 @@ for table in metadata.list_all_entities(entity=Table, limit=100): ``` ```java Iterating Results -import org.openmetadata.client.api.TablesApi; +import org.openmetadata.sdk.models.ListParams; + +// client is an initialized OpenMetadataClient. -TablesApi tablesApi = client.buildClient(TablesApi.class); String afterCursor = null; do { - TableList page = tablesApi.listTables(null, 100, null, afterCursor, null); + var params = new ListParams().setLimit(100); + if (afterCursor != null) { + params.setAfter(afterCursor); + } + var page = client.tables().list(params); - for (Table table : page.getData()) { + for (var table : page.getData()) { System.out.println(table.getFullyQualifiedName()); // Process each table... } diff --git a/v1.13.x/api-reference/sdk/ai-sdk.mdx b/v1.13.x/api-reference/sdk/ai-sdk.mdx index 1264c65b6..29274c369 100644 --- a/v1.13.x/api-reference/sdk/ai-sdk.mdx +++ b/v1.13.x/api-reference/sdk/ai-sdk.mdx @@ -95,7 +95,7 @@ const client = new AISdk({ ```java Java import io.openmetadata.ai.AISdk; -AISdk client = new AISdk.Builder() +AISdk client = AISdk.builder() .host("https://your-openmetadata-instance.com") .token("your-bot-jwt-token") .build(); diff --git a/v1.13.x/api-reference/sdk/go-api-methods.mdx b/v1.13.x/api-reference/sdk/go-api-methods.mdx index 44a19ed8f..259d9d478 100644 --- a/v1.13.x/api-reference/sdk/go-api-methods.mdx +++ b/v1.13.x/api-reference/sdk/go-api-methods.mdx @@ -5,16 +5,15 @@ sidebarTitle: API Methods # Go SDK - API Methods -Once you have instantiated a `Rest` object you can call any of the following methods to perform operations against the OpenMetadata API. +Once you have created a `Client`, call the following methods on any of its services to perform operations against the OpenMetadata API. Examples of services are `client.Tables`, `client.Databases`, and `client.Users`. The examples below use `client.Tables`. They assume `ctx` is a `context.Background()` and that you created `client` as shown in [Go SDK](/v1.13.x/api-reference/sdk/go). -### `Get` method +### `List` Method **Method signature** ```go -func (rest Rest) Get( - path string, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) List( + ctx context.Context, + params *ListTablesParams, +) iter.Seq2[Table, error] ``` **Example** @@ -23,21 +22,22 @@ func (rest Rest) Get( ... func main() { ... - path := "tables" - body, err := rest.Get(path, nil, nil, nil) + for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Name) + } } ``` +`List` fetches the next page of results for you as you loop, so you don't need to handle paging yourself. -### `Post` method +### `GetByID` and `GetByName` Methods **Method signature** ```go -func (rest Rest) Post( - path string, - data map[string]interface{}, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) GetByID(ctx context.Context, id string, params *GetTableByIDParams) (*Table, error) +func (s *TableService) GetByName(ctx context.Context, fqn string, params *GetTableByFQNParams) (*Table, error) ``` **Example** @@ -46,34 +46,45 @@ func (rest Rest) Post( ... func main() { ... - path := "tables" - data := map[string]interface{}{ - "name": "goClientTestTable", - "databaseSchema": "sample_data.ecommerce_db.shopify", - "columns": []map[string]interface{}{ - { - "name": "columnOne", - "dataType": "NUMBER", - }, - { - "name": "columnTwo", - "dataType": "NUMBER", - }, + table, err := client.Tables.GetByName(ctx, "sample_data.ecommerce_db.shopify.dim_customer", nil) + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Id) +} +``` + +### `Create` Method +**Method signature** +```go +func (s *TableService) Create(ctx context.Context, body *CreateTable) (*Table, error) +``` + +**Example** +```go +// main.go +... +func main() { + ... + table, err := client.Tables.Create(ctx, &ometa.CreateTable{ + Name: "goClientTestTable", + DatabaseSchema: "sample_data.ecommerce_db.shopify", + Columns: []ometa.Column{ + {Name: "columnOne", DataType: ometa.ColumnDataTypeNUMBER}, + {Name: "columnTwo", DataType: ometa.ColumnDataTypeNUMBER}, }, + }) + if err != nil { + log.Fatal(err) } - body, err := rest.Post(path, data, nil, nil, nil) + fmt.Println(table.Id) } ``` -### `Put` method +### `CreateOrUpdate` Method **Method signature** ```go -func (rest Rest) Put( - path string, - data map[string]interface{}, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) CreateOrUpdate(ctx context.Context, body *CreateTable) (*Table, error) ``` **Example** @@ -82,38 +93,26 @@ func (rest Rest) Put( ... func main() { ... - path := "tables" - data := map[string]interface{}{ - "name": "goClientTestTable", - "databaseSchema": "sample_data.ecommerce_db.shopify", - "columns": []map[string]interface{}{ - { - "name": "columnOne", - "dataType": "NUMBER", - }, - { - "name": "columnTwo", - "dataType": "NUMBER", - }, - { - "name": "columnThree", - "dataType": "NUMBER", - }, - }, - } - body, err := rest.Put(path, data, nil, nil, nil) + table, err := client.Tables.CreateOrUpdate(ctx, &ometa.CreateTable{ + Name: "goClientTestTable", + DatabaseSchema: "sample_data.ecommerce_db.shopify", + Columns: []ometa.Column{ + {Name: "columnOne", DataType: ometa.ColumnDataTypeNUMBER}, + {Name: "columnTwo", DataType: ometa.ColumnDataTypeNUMBER}, + {Name: "columnThree", DataType: ometa.ColumnDataTypeNUMBER}, + }, + }) + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Id) } ``` -### `Patch` method +### `Patch` Method **Method signature** ```go -func (rest Rest) Patch( - path string, - data []map[string]interface{}, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) Patch(ctx context.Context, id string, ops []JSONPatchOp) (*Table, error) ``` **Example** @@ -122,27 +121,22 @@ func (rest Rest) Patch( ... func main() { ... - path := "tables" - patchPath := fmt.Sprintf("tables/%s", id) - data := []map[string]interface{}{ - { - "op": "add", - "path": "/description", - "value": "This is a test table", - }, - } - body, err := rest.Patch(patchPath, data, nil, nil, nil) + id := table.Id.String() + updated, err := client.Tables.Patch(ctx, id, []ometa.JSONPatchOp{ + {Op: "add", Path: "/description", Value: "This is a test table"}, + }) + if err != nil { + log.Fatal(err) + } + fmt.Println(*updated.Description) } ``` -### `Delete` method +### `Delete` and `DeleteByName` Methods **Method signature** ```go -func (rest Rest) Delete( - path string, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) Delete(ctx context.Context, id string, params *DeleteTableParams) error +func (s *TableService) DeleteByName(ctx context.Context, fqn string, params *DeleteTable1Params) error ``` **Example** @@ -151,11 +145,12 @@ func (rest Rest) Delete( ... func main() { ... - path := fmt.Sprintf("tables/%s", id) - queryParams := map[string]string{ - "hardDelete": "true", - "recursive": "true", - } - rest.Delete(path, nil, nil, queryParams) + err := client.Tables.Delete(ctx, table.Id.String(), &ometa.DeleteTableParams{ + HardDelete: ometa.Bool(true), + Recursive: ometa.Bool(true), + }) + if err != nil { + log.Fatal(err) + } } ``` diff --git a/v1.13.x/api-reference/sdk/go.mdx b/v1.13.x/api-reference/sdk/go.mdx index 3accc2fc8..67959d6ae 100644 --- a/v1.13.x/api-reference/sdk/go.mdx +++ b/v1.13.x/api-reference/sdk/go.mdx @@ -18,49 +18,41 @@ You can add the module to your application with the below command go get github.com/open-metadata/openmetadata-sdk/openmetadata-go-client ``` -## Establish OpenMetadata Server Connection +## Create a Client -To create OpenMetadata Gateway, you will need to establish a connection with *OpenMetadata Server*. The following inputs will be needed: -* `BaseURL`: The url on which your instance of OpenMetadata is up and running (include the port if you need to e.g. `http://localhost:8585`). -* `APIVersion`: pass an empty string -- this will be `v1` for now. -* `Retry`: number of time the request should retry if the status code returned is in `RetryCodes`. Use `0` to use the default value -* `RetryWait`: number of second to wait betwee retries. Pass 0 to use the default value -* `RetryCodes`: HTTP status that will trigger a retry. Pass `nil` to use the default -* `AuthTokenMode`: defaults to `Bearer` -* `AccessToken`: JWT token use to authenticate the request +To talk to OpenMetadata, create a `Client` with the server address and, optionally, settings passed as options: +* `baseURL` (first argument): the address where your OpenMetadata server is running, without the `/api` suffix (include the port if you need to, for example `http://localhost:8585`). The client adds `/api/v1` itself. +* `WithToken(token)`: the JWT token used to authenticate every request. +* `WithAPIVersion(v)`: the API version to call. Defaults to `v1`, so you normally don't set it. +* `WithRetry(count, wait)`: how many times to retry a request, and how long to wait between retries. Defaults to 3 retries, 30 seconds apart. The client retries a request when the server answers `429` or `504`. +* `WithHTTPClient(c)`: use your own `*http.Client`, for example to set a proxy or custom TLS settings. ```go // main.go package main import ( + "context" + "fmt" + "log" + "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" ) func main() { - restConfig := ometa.NewRestConfig( + ctx := context.Background() + client := ometa.NewClient( "http://localhost:8585", - "", // APIVersion - 0, // Retry -> defaults to 3 - 0, // RetryWait -> defaults to 30 seconds - nil, // RetryCodes -> defaults to [429, 504] - "JWTToken", + ometa.WithToken(""), ) -} -``` - - -## Create OpenMetadata Gateway - -Once the connection details are provided, you can create an OpenMetadata Gateway -using the following piece of code. -```go -// main.go -... - -func main() { - ... - rest := ometa.NewRest(restConfig) + for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Name) + } } ``` + +The client has one service for each entity type, such as `client.Tables`, `client.Databases`, and `client.Users`. For more information about the methods every service provides, see [Go SDK - API Methods](/v1.13.x/api-reference/sdk/go-api-methods). diff --git a/v1.13.x/api-reference/sdk/java.mdx b/v1.13.x/api-reference/sdk/java.mdx index 2f32375ff..411309f38 100644 --- a/v1.13.x/api-reference/sdk/java.mdx +++ b/v1.13.x/api-reference/sdk/java.mdx @@ -24,204 +24,148 @@ You can add the below Maven Dependency for the OpenMetadata Java SDK. ``` -## Establish OpenMetadata Server Connection +## Connect to the OpenMetadata Server -To create OpenMetadata Gateway, you will need to establish a connection with *OpenMetadata Server*. The following -inputs will be needed for the same. -* Host Port: The url on which your instance of OpenMetadata is up and running. -* ApiVersion: The value will be "v1". -* Auth Provider: Provide the auth provider with which you need to configure. -* Security Config: Provide the config for the selected auth provider. +To connect to your OpenMetadata server, you need: -```java -OpenMetadataConnection server = new OpenMetadataConnection(); -server.setHostPort("http://localhost:{port}}/api"); -server.setApiVersion("v1"); -server.setAuthProvider(OpenMetadataConnection.AuthProvider.{auth_provider}); -server.setSecurityConfig({security_client_config}); -``` - -## Create OpenMetadata Gateway - -Once the connection details are provided, you can create an OpenMetadata Gateway -using the following piece of code. +* Server URL: The URL where your OpenMetadata instance is running, ending in `/api`. For example, `http://localhost:8585/api`. +* Access token: A JSON Web Token (JWT) for a user or bot. See [Authentication](/v1.13.x/api-reference/authentication) to learn how to get one. ```java -// OpenMetadata Gateway -OpenMetadata openMetadataGateway = new OpenMetadata(server); -``` +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -## Use Java SDK without Authentication -To use the Java SDK without any authentication, you can use `NoOpAuthenticationProvider.java`. \ +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .build(); -```java -NoOpAuthenticationProvider noOpAuthenticationProvider = new NoOpAuthenticationProvider(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` -Establish the [OpenMetadata Server Connection](#establish-openmetadata-server-connection) and provide `noOpAuthenticationProvider` in the config. +Tune the connection with these options. Timeouts are in milliseconds, and `header` adds a custom header to every request: ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.NO_AUTH); +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .connectTimeout(10000) + .readTimeout(30000) + .header("X-Request-Source", "my-app") + .build(); ``` -## Use Java SDK with Authentication. +## Authenticate with a JWT Token -The OpenMetadata Java SDK supports several auth providers: -* [Google](#google) -* [Okta](#okta) -* [Auth0](#auth0) -* [Azure](#azure) -* [OpenMetadata](#openmetadata) +The Java SDK authenticates with a JWT access token that you pass to `accessToken(...)`. This is the same for every sign-in method on your OpenMetadata server, including Google, Okta, Auth0, Azure, and custom OpenID Connect (OIDC). Generate a bot token or a personal access token in OpenMetadata and use it here. -Apart from the above mentioned auth providers, OpenMetadata Java SDK also supports [Custom OIDC](#custom-oidc). +If your server doesn't require authentication, leave out `accessToken(...)`. -### Google -To set up Google as the auth provider, the following details are required: -* Secret Key: Pass the JSON file generated in [Create Service Account](/v1.13.x/deployment/security/google) as the secretKey. +## Use the Fluent API -```java -GoogleSSOClientConfig googleSSOClientConfig = new GoogleSSOClientConfig(); -ssoConfig.setAudience("https://www.googleapis.com/oauth2/v4/token"); -ssoConfig.setSecretKey("{secret_key.json}"); -``` +The fluent classes, such as `Tables`, `Users`, and `Teams`, work with a default client. Register your client once with `OM.init`, and the fluent classes use it: -Provide the Google config while creating the [server connection](#establish-openmetadata-server-connection). ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.GOOGLE); -server.setSecurityConfig(googleSSOClientConfig); +import org.openmetadata.sdk.OM; +import org.openmetadata.sdk.fluent.Tables; -``` +OM.init(client); -### Okta -To set up Okta as the auth provider, the following details should be provided: -* Client ID: Provide the client ID for the service application -* Org URL: It is the same as the ISSUER_URL with v1/token. It is recommended to use a separate authorization server for different applications, rather than using the default authorization server. -* Private Key: Use the Public/Private Key Pair that was generated while [Creating the Service Application](/v1.13.x/deployment/security/okta#okta-sso). When copy-pasting the keys ensure that there are no additional codes and that it is a JSON compatible string. -* Email: Enter the email address -* Scopes: Add the details of the scope created in the Authorization Server. Enter the name of the default scope created. +// Find a table by its fully qualified name +var table = Tables.findByName("mysql-prod.employees.public.employees") + .includeOwners() + .includeTags() + .fetch() + .get(); -```java -OktaSSOClientConfig oktaSSOClientConfig = new OktaSSOClientConfig(); -oktaSSOClientConfig.setClientId("{client_id}"); -oktaSSOClientConfig.setOrgURL("{org_url}/v1/token"); -oktaSSOClientConfig.setPrivateKey("{public/private keypair}"); -oktaSSOClientConfig.setEmail("{email}"); -oktaSSOClientConfig.setScopes({scope_list}); +// Update its description +Tables.findByName("mysql-prod.employees.public.employees") + .fetch() + .withDescription("Updated description") + .save(); ``` -Provide the Okta config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OKTA); -server.setSecurityConfig(oktaSSOClientConfig); -``` +## Use the Service Clients -### Auth0 -To set up Auth0 as the auth provider, the following details are required: -* Client ID: Provide the client ID for the service application -* Secret Key: Provide the client secret. -* Domain: Provide the Auth0 domain. For example `test.us.auth0.com` +Every entity type has a service on the client, such as `client.tables()`, `client.users()`, and `client.dashboards()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. Below are some examples: ```java -Auth0SSOClientConfig auth0SSOClientConfig = new Auth0SSOClientConfig(); -auth0SSOClientConfig.setClientId("{client_id}"); -auth0SSOClientConfig.setSecretKey("{secret_key}"); -auth0SSOClientConfig.setDomain("{domain}"); -``` -Provide the Auth0 config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AUTH_0); -server.setSecurityConfig(auth0SSOClientConfig); -``` +import org.openmetadata.sdk.models.ListParams; -### Azure -To set up Azure as the auth provider, the following details should be provided: -* Client ID: The Application (Client) ID is displayed in the Overview section of the registered application. -* Client Secret: The clientSecret can be accessed from the Certificates & secret section of the application. -* Authority: Use your Microsoft Entra tenant authority. See [Microsoft's OpenID Connect documentation](https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc) for the endpoint format. -* Scopes: Add the details of the scope created. +// Tables +var tables = client.tables().list(new ListParams().setLimit(10)); +for (var table : tables.getData()) { + System.out.println(table.getFullyQualifiedName()); +} -```java -AzureSSOClientConfig azureSSOClientConfig = new AzureSSOClientConfig(); -azureSSOClientConfig.setClientId("{client_id}"); -azureSSOClientConfig.setClientSecret("{client_secret}"); -azureSSOClientConfig.setAuthority("{authority}"); -azureSSOClientConfig.setScopes({scope_list}); -``` -Provide the Azure config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AZURE); -server.setSecurityConfig(azureSSOClientConfig); +// Users +var users = client.users().list(new ListParams().setLimit(10)); + +// Dashboards +var dashboards = client.dashboards().list(new ListParams().setLimit(10)); ``` -### OpenMetadata -To set up OpenMetadata as the auth provider, the following details should be provided: -* JWT Token: Provide the JWT Token. For example `eyJraWQiOiJHYjM4OWEtOWY3Ni1nZGpzLWE5Mmo....XN0aW9uLWJvdEBvcGVubWV0YWRhdGEub3JnIn0.Ku_FHGIS3Id3ARusMaXZDYKcq...Ztap9KDU7nZilNT2Bq-o75aIsgKKmtSuVdBTzpFK8aLGLmRp_8J007t-kpcjIW7Qf0l4...dGb0QqhoZin0JA` +The following examples show how to call an API: + +* Create a table ```java -OpenMetadataJWTClientConfig openMetadataJWTClientConfig = new OpenMetadataJWTClientConfig(); -openMetadataJWTClientConfig.setJwtToken("{jwt_token}"); -``` -Provide the OpenMetadata config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OPENMETADATA); -server.setSecurityConfig(openMetadataJWTClientConfig); -``` +import java.util.List; +import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; -### Custom OIDC -To set up Custom auth provider. The following details are required: -* Client ID: Provide the client ID of the preferred auth provider -* Client Secret: Provide the client secret of your preferred auth provider -* Token Endpoint: Provide the token endpoint of your preferred auth provider +CreateTable request = new CreateTable() + .withName("orders") + .withDatabaseSchema("mysql-prod.employees.public") + .withDescription("Orders placed by customers") + .withColumns(List.of( + new Column() + .withName("order_id") + .withDataType(ColumnDataType.BIGINT) + .withDescription("Primary key"), + new Column() + .withName("status") + .withDataType(ColumnDataType.VARCHAR) + .withDataLength(50))); -```java -CustomOIDCSSOClientConfig customOIDCSSOClientConfig = new CustomOIDCSSOClientConfig(); -config.setClientId("{client_id}"); -config.setSecretKey("{client_secret}"); -config.setTokenEndpoint("{token_endpoint}"); +var table = client.tables().create(request); ``` -Provide the custom auth provider config while creating the [server connection](#establish-openmetadata-server-connection). +* Get a table by fully qualified name + ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.CUSTOM_OIDC); -server.setSecurityConfig(customOIDCSSOClientConfig); +var table = client.tables().getByName("mysql-prod.employees.public.employees", "columns,owners"); ``` -## How to Use APIs Using the Java SDK -You can use an API from the [OpenMetadata Gateway](#create-openmetadata-gateway). -Using OpenMetadata Gateway, you will need to build the client by providing the `class` of the respected API. -Below are some examples: +* Search + ```java -// Dashboards API -DashboardsApi dashboardApi = openMetadataGateway.buildClient(DashboardsApi.class); +String response = client.search() + .query("customer") + .index("table_search_index") + .size(10) + .execute(); +``` -// Tables API -TablesApi tablesApiClient = openMetadataGateway.buildClient(TablesApi.class); +The search call returns the raw JSON response from the server as a string. -// Users API -UsersApi usersApi = openMetadataGateway.buildClient(UsersApi.class); +## Handle Errors -// Locations API -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -``` +When the server returns an error, the SDK throws an `OpenMetadataException`. Use `getStatusCode()` to see which error it was: -Please refer to the examples to access an API: -* Tables API ```java -TablesApi tablesApi = openMetadataGateway.buildClient(TablesApi.class); -tablesApi.addLocationToTable("{table_id}", "{location_id}"); -``` -* Location API -```java -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -CreateLocation createLocation = new CreateLocation(); -Location location = locationsApi.createLocation(createLocation); -``` +import org.openmetadata.sdk.exceptions.OpenMetadataException; -* Elastic Search API -```java -ElasticSearchApi esApi = openMetadataGateway.buildClient(ElasticSearchApi.class); -Response response = esApi.searchEntitiesWithQuery("", "pipeline_search_index", false, 0, 0, null, null, true, "{\"query\":{\"bool\":{}}}", null, false, null ); -String data = IOUtils.toString(response.body().asInputStream(), Charsets.UTF_8); +try { + var table = client.tables().getByName("mysql-prod.employees.public.missing"); +} catch (OpenMetadataException e) { + if (e.getStatusCode() == 404) { + System.out.println("Table not found"); + } else { + System.out.println("Request failed: " + e.getMessage()); + } +} ``` ## More examples diff --git a/v1.13.x/api-reference/sdk/java/info.mdx b/v1.13.x/api-reference/sdk/java/info.mdx index ba454d280..668b4715f 100644 --- a/v1.13.x/api-reference/sdk/java/info.mdx +++ b/v1.13.x/api-reference/sdk/java/info.mdx @@ -6,7 +6,7 @@ sidebarTitle: Java SDK Info # Java SDK -The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers comprehensive support for entity management, authentication, and integration with enterprise Java applications. +The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers support for entity management, search, lineage, and authentication with a JWT token. ## Installation @@ -35,85 +35,87 @@ implementation 'org.open-metadata:openmetadata-sdk:1.13.6' ### Basic Connection ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; -import org.openmetadata.client.auth.BasicAuthProvider; - -// Create client with basic authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new BasicAuthProvider("admin", "admin")) +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.network.HttpMethod; + +// Create a client with a JWT token +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") .build(); -// Health check -if (client.healthCheck()) { - System.out.println("Successfully connected to OpenMetadata!"); -} -``` - -### JWT Authentication - -```java -import org.openmetadata.client.auth.JWTAuthProvider; +OpenMetadataClient client = new OpenMetadataClient(config); -// Create client with JWT authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new JWTAuthProvider("your-jwt-token")) - .build(); +// Check the connection by reading the server version +String version = client.getHttpClient() + .executeForString(HttpMethod.GET, "/v1/system/version", null); +System.out.println("Connected to OpenMetadata: " + version); ``` +For more information about getting a token, see [Authentication](/v1.13.x/api-reference/authentication). + ## Core Functionality ### Working with Entities +Every entity type has a service on the client, such as `client.databaseServices()`, `client.tables()`, and `client.users()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. + #### Database Services ```java -import org.openmetadata.schema.entity.services.DatabaseService; import org.openmetadata.schema.api.services.CreateDatabaseService; +import org.openmetadata.schema.api.services.DatabaseConnection; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.services.connections.database.MysqlConnection; +import org.openmetadata.sdk.models.ListParams; -// List all database services -List services = client.listDatabaseServices(); -System.out.println("Found " + services.size() + " database services"); +// List database services +var services = client.databaseServices().list(new ListParams().setLimit(50)); +System.out.println("Found " + services.getData().size() + " database services"); // Get specific service by name -DatabaseService service = client.getDatabaseServiceByName("mysql-prod"); +DatabaseService service = client.databaseServices().getByName("mysql-prod"); // Create new database service CreateDatabaseService createRequest = new CreateDatabaseService() .withName("new-mysql-service") - .withServiceType(DatabaseServiceType.MYSQL) - .withDescription("Production MySQL database"); - -DatabaseService newService = client.createDatabaseService(createRequest); + .withServiceType(CreateDatabaseService.DatabaseServiceType.Mysql) + .withDescription("Production MySQL database") + .withConnection(new DatabaseConnection().withConfig( + new MysqlConnection() + .withHostPort("localhost:3306") + .withUsername("openmetadata_user"))); + +DatabaseService newService = client.databaseServices().create(createRequest); ``` #### Tables ```java -import org.openmetadata.schema.entity.data.Table; +import java.util.List; import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; +import org.openmetadata.sdk.models.ListParams; // Get table by fully qualified name -Table table = client.getTableByName("mysql-prod.employees.employees"); -if (table != null) { - System.out.println("Table: " + table.getName()); - System.out.println("Columns: " + table.getColumns().size()); -} +Table table = client.tables().getByName("mysql-prod.employees.public.employees", "columns"); +System.out.println("Table: " + table.getName()); +System.out.println("Columns: " + table.getColumns().size()); -// List tables with pagination -EntityList
tables = client.listTables( - 10, // limit - null, // after cursor - "mysql-prod" // service filter -); +// List tables in a schema with pagination +var tables = client.tables().list( + new ListParams() + .setLimit(10) + .addFilter("databaseSchema", "mysql-prod.employees.public")); // Create table CreateTable createTable = new CreateTable() .withName("new_table") - .withDatabaseSchema("mysql-prod.employees") - .withColumns(Arrays.asList( + .withDatabaseSchema("mysql-prod.employees.public") + .withColumns(List.of( new Column() .withName("id") .withDataType(ColumnDataType.BIGINT) @@ -125,7 +127,7 @@ CreateTable createTable = new CreateTable() .withDescription("Employee name") )); -Table newTable = client.createTable(createTable); +Table newTable = client.tables().create(createTable); ``` ### Entity Operations @@ -133,111 +135,83 @@ Table newTable = client.createTable(createTable); #### CRUD Operations ```java -// Create or Update -DatabaseService service = client.createOrUpdateDatabaseService(createRequest); +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.network.HttpMethod; + +// Create or update a table +Table table = client.tables().createOrUpdate(createTable); + +// Create or update a database service +DatabaseService service = client.getHttpClient().execute( + HttpMethod.PUT, "/v1/services/databaseServices", createRequest, DatabaseService.class); // Get by ID -UUID serviceId = UUID.fromString("service-uuid-here"); -DatabaseService service = client.getDatabaseServiceById(serviceId); +UUID serviceId = service.getId(); +DatabaseService sameService = client.databaseServices().get(serviceId); // Delete -client.deleteDatabaseService(serviceId, false); // soft delete -client.deleteDatabaseService(serviceId, true); // hard delete +client.databaseServices().delete(serviceId.toString()); // soft delete +client.databaseServices().delete(serviceId.toString(), Map.of("hardDelete", "true")); // hard delete ``` #### Search and Filtering ```java -// Search tables -SearchRequest searchRequest = new SearchRequest() - .withQuery("customer") - .withEntityTypes(Arrays.asList("table")) - .withSize(50); - -SearchResponse results = client.search(searchRequest); -for (SearchHit hit : results.getHits()) { - System.out.println("Found: " + hit.getDisplayName()); -} +import org.openmetadata.sdk.models.ListParams; + +// Search tables. The response is the raw JSON from the server. +String results = client.search() + .query("customer") + .index("table_search_index") + .size(50) + .execute(); +System.out.println(results); // Advanced filtering -EntityList
customerTables = client.listTables( - 100, - null, - Map.of( - "service", "mysql-prod", - "database", "ecommerce" - ) -); +var customerTables = client.tables().list( + new ListParams() + .setLimit(100) + .addFilter("database", "mysql-prod.ecommerce")); ``` ## Advanced Features -### Authentication Providers - -#### Custom Authentication - -```java -import org.openmetadata.client.auth.AuthProvider; - -public class CustomAuthProvider implements AuthProvider { - private String customToken; - - public CustomAuthProvider(String token) { - this.customToken = token; - } - - @Override - public String getAuthToken() { - return "Bearer " + customToken; - } - - @Override - public void refresh() { - // Implement token refresh logic - } -} - -// Use custom auth provider -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(new CustomAuthProvider("custom-token")) - .build(); -``` +### Authentication -#### OAuth 2.0 Integration +The Java SDK authenticates with a JWT access token. When your token changes, create a new client with the new token: ```java -import org.openmetadata.client.auth.OAuth2AuthProvider; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -OAuth2AuthProvider authProvider = OAuth2AuthProvider.builder() - .clientId("your-client-id") - .clientSecret("your-client-secret") - .tokenUrl("https://auth.provider.com/oauth/token") - .scopes(Arrays.asList("read", "write")) - .build(); +String newToken = "your-new-jwt-token"; -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(authProvider) - .build(); +OpenMetadataClient client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl("https://your-instance.com/api") + .accessToken(newToken) + .build()); ``` ### Error Handling ```java -import org.openmetadata.client.exception.OpenMetadataException; +import org.openmetadata.sdk.exceptions.OpenMetadataException; try { - Table table = client.getTableByName("non-existent-table"); + var table = client.tables().getByName("non-existent-table"); } catch (OpenMetadataException e) { - switch (e.getErrorCode()) { - case NOT_FOUND: + switch (e.getStatusCode()) { + case 404: System.out.println("Table not found"); break; - case UNAUTHORIZED: + case 401: System.out.println("Authentication failed"); break; - case FORBIDDEN: + case 403: System.out.println("Access denied"); break; default: @@ -248,15 +222,22 @@ try { ### Async Operations +The service methods are blocking. To run them in parallel, wrap them in a `CompletableFuture`: + ```java +import java.util.List; import java.util.concurrent.CompletableFuture; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.models.ListParams; -// Async client operations CompletableFuture> servicesFuture = - client.listDatabaseServicesAsync(); + CompletableFuture.supplyAsync( + () -> client.databaseServices().list(new ListParams().setLimit(50)).getData()); CompletableFuture
tableFuture = - client.getTableByNameAsync("mysql-prod.employees.employees"); + CompletableFuture.supplyAsync( + () -> client.tables().getByName("mysql-prod.employees.public.employees", "columns")); // Combine async operations CompletableFuture combinedFuture = CompletableFuture.allOf( @@ -280,39 +261,19 @@ CompletableFuture combinedFuture = CompletableFuture.allOf( ### Client Configuration ```java -import org.openmetadata.client.config.ClientConfig; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -ClientConfig config = ClientConfig.builder() - .connectionTimeout(30000) // 30 seconds +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .connectTimeout(30000) // 30 seconds .readTimeout(60000) // 60 seconds - .retryCount(3) // Retry failed requests 3 times - .enableLogging(true) // Enable request/response logging - .enableMetrics(true) // Enable client metrics - .userAgent("MyApp/1.0") // Custom user agent + .writeTimeout(60000) // 60 seconds + .header("User-Agent", "MyApp/1.0") // Custom header on every request .build(); -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(authProvider) - .config(config) - .build(); -``` - -### Connection Pooling - -```java -import org.openmetadata.client.config.ConnectionPoolConfig; - -ConnectionPoolConfig poolConfig = ConnectionPoolConfig.builder() - .maxTotal(100) // Maximum total connections - .maxPerRoute(20) // Maximum connections per route - .connectionTTL(300000) // Connection TTL in milliseconds - .validateAfterInactivity(10000) // Validate connections after 10s - .build(); - -ClientConfig config = ClientConfig.builder() - .connectionPoolConfig(poolConfig) - .build(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ## Common Use Cases @@ -320,15 +281,26 @@ ClientConfig config = ClientConfig.builder() ### Metadata Discovery ```java -// Discover all tables in a service -String serviceName = "mysql-prod"; +import java.util.ArrayList; +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + +// Discover all tables in a schema +String schemaName = "mysql-prod.employees.public"; List
allTables = new ArrayList<>(); String after = null; do { - EntityList
batch = client.listTables(100, after, serviceName); + var params = new ListParams() + .setLimit(100) + .addFilter("databaseSchema", schemaName); + if (after != null) { + params.setAfter(after); + } + var batch = client.tables().list(params); allTables.addAll(batch.getData()); - after = batch.getAfter(); + after = batch.getPaging().getAfter(); } while (after != null); System.out.println("Discovered " + allTables.size() + " tables"); @@ -337,17 +309,19 @@ System.out.println("Discovered " + allTables.size() + " tables"); ### Bulk Operations ```java +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + // Bulk update table descriptions -List
tables = client.listAllTablesInService("mysql-prod"); +List
tables = client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", "mysql-prod.employees.public")) + .getData(); for (Table table : tables) { if (table.getDescription() == null || table.getDescription().isEmpty()) { - CreateTable updateRequest = new CreateTable() - .withName(table.getName()) - .withDatabaseSchema(table.getDatabaseSchema().getFullyQualifiedName()) - .withDescription("Auto-generated description for " + table.getName()); - - client.createOrUpdateTable(updateRequest); + table.setDescription("Auto-generated description for " + table.getName()); + client.tables().update(table.getId().toString(), table); } } ``` @@ -355,87 +329,61 @@ for (Table table : tables) { ### Lineage Operations ```java -import org.openmetadata.schema.type.EntityLineage; - -// Get table lineage -EntityLineage lineage = client.getTableLineage( - "mysql-prod.employees.employees", - 1, // upstream depth - 1 // downstream depth +// Get table lineage as JSON (1 hop upstream, 1 hop downstream) +String lineage = client.lineage().getLineageByName( + "table", + "mysql-prod.employees.public.employees", + "1", // upstream depth + "1" // downstream depth ); -System.out.println("Upstream entities: " + lineage.getUpstreamEdges().size()); -System.out.println("Downstream entities: " + lineage.getDownstreamEdges().size()); +System.out.println(lineage); ``` -## Spring Boot Integration +For more information about the fluent API for lineage, see [Java SDK for Lineage](/v1.13.x/api-reference/sdk/java/lineage). -### Configuration Class +## Use the Client in Your Application -```java -@Configuration -@EnableConfigurationProperties(OpenMetadataProperties.class) -public class OpenMetadataConfig { - - @Bean - public OpenMetadataClient openMetadataClient(OpenMetadataProperties properties) { - return OpenMetadataClient.builder() - .baseUrl(properties.getBaseUrl()) - .authProvider(new JWTAuthProvider(properties.getJwtToken())) - .build(); - } -} - -@ConfigurationProperties(prefix = "openmetadata") -@Data -public class OpenMetadataProperties { - private String baseUrl; - private String jwtToken; -} -``` - -### Service Layer +Create one `OpenMetadataClient` and share it across your application. If you use a framework such as Spring Boot, register the client as a singleton bean. ```java -@Service -public class MetadataService { +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.models.ListParams; - private final OpenMetadataClient client; +class MetadataService { - public MetadataService(OpenMetadataClient client) { - this.client = client; - } + private final OpenMetadataClient client; - public List
getTablesForService(String serviceName) { - return client.listAllTablesInService(serviceName); + public MetadataService(String baseUrl, String jwtToken) { + this.client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl(baseUrl) + .accessToken(jwtToken) + .build()); } - public Table createTable(CreateTableRequest request) { - CreateTable createTable = new CreateTable() - .withName(request.getName()) - .withDatabaseSchema(request.getSchemaFqn()) - .withColumns(request.getColumns()); - - return client.createTable(createTable); + public java.util.List getTablesForSchema(String schemaFqn) { + return client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", schemaFqn)) + .getData(); } } ``` ## Best Practices -1. **Resource Management**: Always close clients when done -2. **Connection Pooling**: Use connection pooling for high-throughput applications -3. **Error Handling**: Implement proper retry logic and error handling -4. **Authentication**: Use secure authentication methods in production -5. **Async Operations**: Use async methods for better performance in concurrent scenarios -6. **Pagination**: Always handle pagination for large datasets -7. **Caching**: Implement caching for frequently accessed entities +- **Reuse the client**: Create one client and share it instead of creating a new one per request. +- **Handle errors**: Catch `OpenMetadataException` and check the status code. +- **Protect authentication**: Keep your JWT token in a secret store, not in source code. +- **Use async operations**: Wrap calls in `CompletableFuture` for better performance in concurrent scenarios. +- **Handle pagination**: Always handle pagination for large datasets. +- **Cache entities**: Implement caching for frequently accessed entities. ## Performance Tips -- Use batch operations when possible -- Implement connection pooling for high-concurrency applications -- Cache frequently accessed metadata -- Use async operations for better throughput -- Specify only required fields when fetching entities -- Implement proper retry strategies with exponential backoff \ No newline at end of file +- Create one client and reuse it. +- Cache frequently accessed metadata. +- Run independent calls in parallel with `CompletableFuture`. +- Specify only required fields when fetching entities. +- Use filters to narrow lists before you read them. diff --git a/v1.13.x/api-reference/sdk/java/lineage.mdx b/v1.13.x/api-reference/sdk/java/lineage.mdx index 4ed1ded83..2a547fda2 100644 --- a/v1.13.x/api-reference/sdk/java/lineage.mdx +++ b/v1.13.x/api-reference/sdk/java/lineage.mdx @@ -24,12 +24,15 @@ Before using the fluent API, initialize the client: ```java import org.openmetadata.sdk.api.Lineage; import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .jwtToken("") +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("") .build(); +OpenMetadataClient client = new OpenMetadataClient(config); + Lineage.setDefaultClient(client); ``` @@ -38,6 +41,8 @@ Lineage.setDefaultClient(client); Retrieve the lineage graph for an entity by type and ID: ```java +import org.openmetadata.sdk.api.Lineage; + // Get lineage with default depth (1 upstream, 1 downstream) Lineage.LineageGraph graph = Lineage.of("table", tableId).fetch(); @@ -47,9 +52,11 @@ String raw = graph.getRaw(); ### Custom Depth -Control how many hops upstream and downstream are returned: +Control how many hops upstream and downstream are returned. Use a depth of 3 or less, because the server rejects deeper requests: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageGraph graph = Lineage.of("table", tableId) .upstream(3) .downstream(2) @@ -59,14 +66,18 @@ Lineage.LineageGraph graph = Lineage.of("table", tableId) Or set both directions to the same value: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageGraph graph = Lineage.of("table", tableId) - .depth(5) + .depth(3) .fetch(); ``` ### Include Deleted Entities ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageGraph graph = Lineage.of("table", tableId) .includeDeleted(true) .fetch(); @@ -77,6 +88,8 @@ Lineage.LineageGraph graph = Lineage.of("table", tableId) Use `Lineage.connect()` to create an edge between two entities: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("dashboard", dashboardId) @@ -89,6 +102,8 @@ Lineage.LineageEdge edge = Lineage.connect() Map specific columns from the source entity to columns in the target entity: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .fromColumns("customer_id", "order_date") @@ -106,6 +121,8 @@ a `columnsLineage` array inside `lineageDetails`. Associate a pipeline entity that powers the transformation: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("table", targetTableId) @@ -119,6 +136,8 @@ Lineage.LineageEdge edge = Lineage.connect() Attach the SQL query driving the lineage: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("table", targetTableId) @@ -131,6 +150,8 @@ Lineage.LineageEdge edge = Lineage.connect() Combine all options: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .fromColumns("customer_id", "order_date") @@ -147,6 +168,8 @@ Lineage.LineageEdge edge = Lineage.connect() Remove a lineage edge between two entities: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.disconnect() .from("table", sourceTableId) .to("dashboard", dashboardId) @@ -158,6 +181,8 @@ Lineage.disconnect() Export the lineage graph for a given entity by its fully qualified name: ```java +import org.openmetadata.sdk.api.Lineage; + String csv = Lineage.export() .entity("table", "service.database.schema.my_table") .upstream(3) @@ -167,28 +192,37 @@ String csv = Lineage.export() ## Impact Analysis -Analyze which downstream (or upstream) entities are affected by changes to a given entity: +To find the entities affected by a change, fetch the lineage graph in one direction and read the entities from the raw JSON. The `nodes` array lists every entity in the graph. ### Downstream Impact ```java -Lineage.ImpactAnalysis impact = Lineage.impact() - .of("table", tableId) - .downstream() - .depth(3) - .analyze(); +import org.openmetadata.sdk.api.Lineage; -int totalImpacted = impact.getTotalImpactCount(); +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +Lineage.LineageGraph graph = Lineage.of("table", tableId) + .upstream(0) + .downstream(3) + .fetch(); + +JsonNode lineage = new ObjectMapper().readTree(graph.getRaw()); +for (JsonNode node : lineage.path("nodes")) { + System.out.println(node.path("type").asText() + ": " + node.path("fullyQualifiedName").asText()); +} +System.out.println("Impacted entities: " + lineage.path("nodes").size()); ``` ### Upstream Impact ```java -Lineage.ImpactAnalysis impact = Lineage.impact() - .of("dashboard", dashboardId) - .upstream() - .depth(5) - .analyze(); +import org.openmetadata.sdk.api.Lineage; + +Lineage.LineageGraph graph = Lineage.of("dashboard", dashboardId) + .upstream(3) + .downstream(0) + .fetch(); ``` ## OpenLineage Events @@ -197,6 +231,8 @@ The SDK also supports posting [OpenLineage](https://openlineage.io/) standard ev via the `OpenLineage` fluent API: ```java +import org.openmetadata.sdk.api.Lineage; + import org.openmetadata.sdk.fluent.OpenLineage; OpenLineage.setDefaultClient(client); @@ -206,7 +242,7 @@ String response = OpenLineage.event() .withEventType("COMPLETE") .withEventTime("2024-01-15T12:00:00Z") .withJob("my-etl-job", "my-namespace") - .withRun("run-id-123") + .withRun("3f2b9c1e-5d4a-4e7b-8a6c-1d2e3f4a5b6c") .addInput("source_table", "my-namespace") .addOutput("target_table", "my-namespace") .send(); @@ -215,18 +251,20 @@ String response = OpenLineage.event() ### Batch Events ```java +import org.openmetadata.sdk.fluent.OpenLineage; + // Build individual events OpenLineage.RunEventBuilder event1 = OpenLineage.event() .withEventType("START") .withEventTime("2024-01-15T12:00:00Z") .withJob("job-1", "ns") - .withRun("run-1"); + .withRun("7a1c2d3e-4b5f-4a6b-9c8d-0e1f2a3b4c5d"); OpenLineage.RunEventBuilder event2 = OpenLineage.event() .withEventType("COMPLETE") .withEventTime("2024-01-15T12:05:00Z") .withJob("job-1", "ns") - .withRun("run-1"); + .withRun("7a1c2d3e-4b5f-4a6b-9c8d-0e1f2a3b4c5d"); // Send as a batch String response = OpenLineage.batch() @@ -238,25 +276,32 @@ String response = OpenLineage.batch() ## Static API For simpler use cases, the `LineageAPI` class in `org.openmetadata.sdk.api` provides static methods -that wrap the underlying HTTP calls: +that wrap the underlying HTTP calls. They use a shared client, which you set up once with `OpenMetadata.initialize`: ```java +import java.util.Map; import org.openmetadata.sdk.api.LineageAPI; +import org.openmetadata.sdk.client.OpenMetadata; + +OpenMetadata.initialize("http://localhost:8585/api", ""); // Get lineage by entity FQN -String lineage = LineageAPI.getLineage("service.db.schema.table"); +String lineage = LineageAPI.getLineage("table/name/service.db.schema.table"); // Get lineage with depth -String lineage = LineageAPI.getLineage("service.db.schema.table", "3", "2"); +String lineageWithDepth = LineageAPI.getLineage("table/name/service.db.schema.table", "3", "2"); // Get lineage by entity type and ID -String lineage = LineageAPI.getEntityLineage("table", tableId); +String lineageById = LineageAPI.getEntityLineage("table", tableId); // Add lineage (pass a Map matching the AddLineage JSON schema) +Map lineageRequestMap = Map.of("edge", Map.of( + "fromEntity", Map.of("id", sourceTableId, "type", "table"), + "toEntity", Map.of("id", targetTableId, "type", "table"))); String result = LineageAPI.addLineage(lineageRequestMap); // Delete lineage -String result = LineageAPI.deleteLineage("table:fromId", "dashboard:toId"); +String deleted = LineageAPI.deleteLineage("table:" + sourceTableId, "dashboard:" + dashboardId); // Export lineage String csv = LineageAPI.exportLineage("service.db.schema.table", "table", "3", "2"); @@ -267,9 +312,13 @@ String csv = LineageAPI.exportLineage("service.db.schema.table", "table", "3", " All static methods have `CompletableFuture`-based async variants: ```java -CompletableFuture future = LineageAPI.getLineageAsync("service.db.schema.table"); +import java.util.concurrent.CompletableFuture; +import org.openmetadata.sdk.api.LineageAPI; + +CompletableFuture future = LineageAPI.getLineageAsync("table/name/service.db.schema.table"); future.thenAccept(lineage -> System.out.println("Lineage: " + lineage)); -CompletableFuture addFuture = LineageAPI.addLineageAsync(request); -CompletableFuture deleteFuture = LineageAPI.deleteLineageAsync("table:id1", "dashboard:id2"); +CompletableFuture addFuture = LineageAPI.addLineageAsync(lineageRequestMap); +CompletableFuture deleteFuture = LineageAPI.deleteLineageAsync( + "table:" + sourceTableId, "dashboard:" + dashboardId); ``` diff --git a/v1.13.x/api-reference/sdk/overview.mdx b/v1.13.x/api-reference/sdk/overview.mdx index 013a8fa2c..f16170c11 100644 --- a/v1.13.x/api-reference/sdk/overview.mdx +++ b/v1.13.x/api-reference/sdk/overview.mdx @@ -2,6 +2,8 @@ title: OpenMetadata SDKs description: 'Official client libraries for Python, Java, and Go to integrate with OpenMetadata APIs. Type-safe, full-featured SDKs for metadata management and automation.' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # OpenMetadata SDKs @@ -25,7 +27,7 @@ Official client libraries provide type-safe, full-featured access to OpenMetadat - Full-featured Python client + Original Client and SDK 2.0 (`metadata.sdk`) Enterprise Java integration @@ -44,15 +46,24 @@ Perfect for: - ML pipeline automation - Data quality automation +SDK 2.0 (`metadata.sdk`, OpenMetadata 1.10.0 and later): + + + +Original client: + ```python from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( OpenMetadataConnection, ) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) from metadata.ingestion.ometa.ometa_api import OpenMetadata server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -69,13 +80,15 @@ Perfect for: - Legacy system integration ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; + +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .build(); -OpenMetadataClient client = new OpenMetadataClient( - "http://localhost:8585/api", - "your-jwt-token" -); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ### Go SDK @@ -86,11 +99,11 @@ Perfect for: - High-performance services ```go -import "github.com/open-metadata/openmetadata-go-client" +import "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" -client := openmetadata.NewClient( - "http://localhost:8585/api", - "your-jwt-token", +client := ometa.NewClient( + "http://localhost:8585", + ometa.WithToken("your-jwt-token"), ) ``` diff --git a/v1.13.x/api-reference/sdk/python.mdx b/v1.13.x/api-reference/sdk/python.mdx index 2b2c2dd2b..ab595c978 100644 --- a/v1.13.x/api-reference/sdk/python.mdx +++ b/v1.13.x/api-reference/sdk/python.mdx @@ -3,6 +3,8 @@ title: Python SDK | OpenMetadata Python SDK Documentation description: Master OpenMetadata'sPython SDK with comprehensive documentation, code examples, and API guides. Build powerful data discovery and governance solutions. sidebarTitle: Overview --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -17,7 +19,7 @@ We are now going to present a high-level Python API as a type-safe and gentle wr - Make sure to use the same `openmetadata-ingestion` version as your server version. For example, if you have the OpenMetadata server at version 1.13.6, you will need to install: -```python +```bash pip install "openmetadata-ingestion~=1.13.6.0" ``` @@ -30,7 +32,15 @@ In the [OpenMetadata Design](/v1.13.x/developers/architecture), we have been dis This means that whenever we need to interact with the metadata system or develop a new connector or logic, we have to make sure that we pass the proper inputs and handle the types of outputs. -## Introducing the Python API + + +## SDK 2.0 Quick Start + +Connect with `configure()`, then create, update, and delete a table: + + + +## Introducing the Python API (Original Client) Let's suppose that we have our local OpenMetadata server running at `http:localhost:8585`. We can play with it with simple `cURL` or `httpie` commands, and if we just want to take a look at the Entity instances we have lying around, that might probably be enough. However, let's imagine that we want to create or update an ML Model Entity with a `PUT`. To do so, we need to make sure that we are providing a proper JSON, covering all the attributes and types required by the Entity definition. @@ -202,7 +212,7 @@ server_config = OpenMetadataConnection( securityConfig=OpenMetadataJWTClientConfig( jwtToken="", ), - verifySSL="validate" # ignore, validate or no-ssl, + verifySSL="validate", # ignore, validate or no-ssl sslConfig=ValidateSslClientConfig(caCertificate="/path/to/rootCert"), ) @@ -316,8 +326,8 @@ class CreateDatabaseRequest(BaseModel): None, description='Description of the database instance. What it has and how to use it.', ) - owner: Optional[entityReference.EntityReference] = Field( - None, description='Owner of this database' + owners: Optional[entityReferenceList.EntityReferenceList] = Field( + None, description='Owners of this database' ) service: basic.FullyQualifiedEntityName = Field( ..., @@ -331,7 +341,7 @@ class CreateDatabaseRequest(BaseModel): Note how the only non-optional fields are `name` and `service`. The type of `service`, however, is `FullyQualifiedEntityName`. This is expected, as there we need to pass the information of an existing Entity. In our case, the `fullyQualifiedName` of the `DatabaseService` we just created. -In the case of the `owner` field, repeating the exercise and reviewing the required fields to instantiate an `EntityReference` we notice how we need to pass an `id: uuid.UUID` and `type: str`. There we need to specify the `id` and `type` of an `User`. +The `owners` field takes a list of `EntityReference`. To instantiate an `EntityReference`, pass an `id: uuid.UUID` and `type: str`. Specify the `id` and `type` of a `User`. **Querying by name** @@ -400,8 +410,8 @@ Let's now update the `Table` by adding an owner. This will require us to create First, make sure that no owner has been set during the creation: ```python -print(table_entity.owner) -# None +print(table_entity.owners) +# root=[] ``` Now, create a `User`: @@ -414,19 +424,19 @@ user = metadata.create_or_update( ) ``` -Update our instance of `create_table` to add the `owner` field (we need to use the `Create` class as we'll run a `PUT`), and update the Entity: +Update your `create_table` instance to add the `owners` field. Use the `Create` class, because this runs a `PUT`. Then update the Entity: ```python from metadata.generated.schema.type.entityReference import EntityReference -create_table.owner = EntityReference(id=user.id, type="user") +create_table.owners = [EntityReference(id=user.id, type="user")] updated_table_entity = metadata.create_or_update(create_table) -print(updated_table_entity.owner) -# EntityReference(id=Uuid(__root__=UUID('48793f0c-5308-45c1-9bf4-06a82c8d7bf9')), type='user', name='random-user', description=None, displayName=None, href=Href(__root__=AnyUrl('http://localhost:8585/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9', scheme='http', host='localhost', host_type='int_domain', port='8585', path='/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9'))) +print(updated_table_entity.owners.root[0].name) +# random-user ``` -If we did not save the `updated_table_entity` variable, we should need to query it to review the `owner` field. We can run the `get_by_name` using the proper FQN definition for `Table`s: +If you didn't save the `updated_table_entity` variable, query it to review the `owners` field. Run `get_by_name` with the FQN of the table: ```python my_table = metadata.get_by_name(entity=Table, fqn="test-service-table.test-db.test-schema.test") diff --git a/v1.13.x/api-reference/sdk/python/entities/ml-model.mdx b/v1.13.x/api-reference/sdk/python/entities/ml-model.mdx index a98fe9a77..1c51dd763 100644 --- a/v1.13.x/api-reference/sdk/python/entities/ml-model.mdx +++ b/v1.13.x/api-reference/sdk/python/entities/ml-model.mdx @@ -35,7 +35,7 @@ There are some common questions with lifecycle tools, such as _Where (URL) is th This information, together with the rest of the features brought by OpenMetadata, lets us also manage topics such as schema changes in the sources or feature drifts, with the corresponding alerting systems. -While we can already extract certain pieces of information automatically via our Connectors (e.g., [Mlflow](/v1.13.x/connectors/ml-model/mlflow)), there are attributes that we'll need to fill in by ourselves. Thanks to the [Solution Design](/v1.13.x/main-concepts/high-level-design) of OpenMetadata and the [Python SDK](/v1.13.x/api-reference/sdk/python), this is going to be a rather easy task that will unlock the full power of your **organization's metadata**. +While we can already extract certain pieces of information automatically via our Connectors, for example [Mlflow](/v1.13.x/connectors/ml-model/mlflow), there are attributes that we'll need to fill in by ourselves. Thanks to the [Solution Design](/v1.13.x/main-concepts/high-level-design) of OpenMetadata and the [Python SDK](/v1.13.x/api-reference/sdk/python), this is going to be a rather easy task that will unlock the full power of your **organization's metadata**. ## Properties Now that we have a clearer view of what we are trying to achieve, let's jump into a deeper view on the `MlModel` Entity [definition](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/entity/data/mlmodel.json): @@ -43,7 +43,7 @@ Now that we have a clearer view of what we are trying to achieve, let's jump int - The `name` and `algorithm` are the only required properties when [creating](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/api/data/createMlModel.json) an `MlModel`. We can just bring the top shell to the catalogue automatically and then choose which models we want to enrich. - The `dashboard` is a reference to a Dashboard Entity present in OpenMetadata (what we call an `EntityReference`). This should be a dashboard we have built that shows the evolution of our performance metrics. The **transparency** on ML services is integral, and that is why we have added it to the `MlModel` properties. - A server with the URL on where to reach the model **endpoint**, to `POST` input data or retrieve a prediction. -- The mlStore specifies the **location** containing the model. Here we support both passing a URI with the object (e.g. `pkl`) location and/or a Docker image in its repository. +- The mlStore specifies the **location** containing the model. Here we support both passing a URI with the object, for example `pkl` location and/or a Docker image in its repository. - With `mlHyperParameters` we can add the `name`, `value` and `description` of the used hyperparameters. On top of this information, we can also have common metadata attributes, such as the Owner, tags, followers or **versioning**. @@ -80,7 +80,7 @@ MlFeature( Some properties that we can define when instantiating an `MlFeature` are the name, the `dataType` and the `featureAlgorithm`. Now, the question is: Are we being thorough in describing what is really going on? Are we going to be able to detect at any point in the future if this model is based on biased predictors (such as gender)? -Here we want to give more **depth**. In order to do so, we can inform another property of the `MlFeature`, which are the `MlFeatureSource`s. The idea is that any feature can be based on an arbitrary number of real/physical sources (e.g., the columns of a Table), and informing this field will allow us to obtain this **relationship**. +Here we want to give more **depth**. In order to do so, we can inform another property of the `MlFeature`, which are the `MlFeatureSource`s. The idea is that any feature can be based on an arbitrary number of real/physical sources, for example the columns of a Table, and informing this field will allow us to obtain this **relationship**. If we add this extra information, our feature will look like this: @@ -117,9 +117,18 @@ Thanks to this extra piece of information, we now can run the following method o ```python from metadata.ingestion.ometa.ometa_api import OpenMetadata -from metadata.ingestion.ometa.openmetadata_rest import MetadataServerConfig +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) -server_config = MetadataServerConfig(api_endpoint="http://localhost:8585/api") +server_config = OpenMetadataConnection( + hostPort="http://localhost:8585/api", + authProvider="openmetadata", + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), +) metadata = OpenMetadata(server_config) metadata.add_mlmodel_lineage(model=my_mlmodel_entity) diff --git a/v1.13.x/api-reference/sdk/python/overview.mdx b/v1.13.x/api-reference/sdk/python/overview.mdx index c193ace70..828043502 100644 --- a/v1.13.x/api-reference/sdk/python/overview.mdx +++ b/v1.13.x/api-reference/sdk/python/overview.mdx @@ -1,7 +1,10 @@ --- title: Python SDK Overview +sidebarTitle: Original Client and SDK 2.0 description: 'Full-featured Python client library for OpenMetadata integration' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -15,7 +18,17 @@ Install the OpenMetadata Python SDK using pip: pip install openmetadata-ingestion ``` -## Quick Start + + +## Quick Start: SDK 2.0 + +Connect with `configure()`, then create, update, and delete a table: + + + +## Quick Start: Original Client + +Connect with `OpenMetadataConnection`, then read and update entities: ### Basic Connection @@ -31,7 +44,7 @@ from metadata.generated.schema.security.client.openMetadataJWTClientConfig impor # Configure connection server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -62,7 +75,7 @@ table = metadata.get_by_name( ) if table: - print(f"Table: {table.name}") + print(f"Table: {table.name.root}") print(f"Columns: {len(table.columns) if table.columns else 0}") ``` @@ -106,7 +119,7 @@ table = metadata.get_by_name( # List entities with pagination tables = metadata.list_entities( entity=Table, - fields=["owner", "tags"], + fields=["owners", "tags"], limit=50 ) ``` @@ -117,12 +130,12 @@ tables = metadata.list_entities( # Generator for large datasets all_tables = metadata.list_all_entities( entity=Table, - fields=["owner", "columns"], - params={"service": "your-service-name"} + fields=["owners", "columns"], + params={"databaseSchema": "your-service.your-database.your-schema"} ) for table in all_tables: - print(f"Processing table: {table.name}") + print(f"Processing table: {table.name.root}") ``` ### Entity References @@ -136,26 +149,26 @@ table_ref = metadata.get_entity_reference( # Use in other entity creation if table_ref: - print(f"Table reference: {table_ref.id}") + print(f"Table reference: {table_ref.id.root}") ``` ## Advanced Features -### Custom Configuration +### Validating a Custom Certificate Authority (CA) Certificate + +To trust a private CA, pass the path to its certificate in `sslConfig`: ```python -# Using custom authentication -from metadata.generated.schema.security.client.basicAuthenticationProvider import ( - BasicAuthenticationProvider, -) +from metadata.generated.schema.security.ssl.validateSSLClientConfig import ValidateSslClientConfig server_config = OpenMetadataConnection( hostPort="https://your-openmetadata-instance.com/api", - authProvider="basic", - securityConfig=BasicAuthenticationProvider( - username="your-username", - password="your-password" + authProvider="openmetadata", + securityConfig=OpenMetadataJWTClientConfig( + jwtToken="your-jwt-token" ), + verifySSL="validate", + sslConfig=ValidateSslClientConfig(caCertificate="/path/to/rootCert"), ) metadata = OpenMetadata(server_config) @@ -164,18 +177,10 @@ metadata = OpenMetadata(server_config) ### Error Handling ```python -from metadata.ingestion.ometa.ometa_api import ( - OpenMetadata, - InvalidEntityException, - EmptyPayloadException -) - -try: - table = metadata.get_by_name(entity=Table, fqn="non-existent-table") -except InvalidEntityException as e: - print(f"Invalid entity: {e}") -except EmptyPayloadException as e: - print(f"No data received: {e}") +# get_by_name returns None when the entity does not exist +table = metadata.get_by_name(entity=Table, fqn="non-existent-table") +if table is None: + print("Table not found") ``` ### Working with Versions @@ -200,11 +205,11 @@ all_tables = metadata.list_all_entities(entity=Table) matching_tables = [ table for table in all_tables - if "customer" in table.name.lower() + if "customer" in table.name.root.lower() ] for table in matching_tables: - print(f"Found customer table: {table.fullyQualifiedName}") + print(f"Found customer table: {table.fullyQualifiedName.root}") ``` ### Metadata Automation @@ -213,30 +218,28 @@ for table in matching_tables: # Bulk update table descriptions tables_to_update = metadata.list_all_entities( entity=Table, - params={"service": "production-db"} + params={"databaseSchema": "production-service.production-db.public"} ) for table in tables_to_update: if not table.description: # Update with a default description - table.description = f"Production table: {table.name}" + table.description = f"Production table: {table.name.root}" metadata.create_or_update(data=table) ``` ### Lineage Management ```python -from metadata.generated.schema.type.entityLineage import EntityLineage - -# Get table lineage +# Get table lineage (returns a dict) lineage = metadata.get_lineage_by_name( entity=Table, fqn="service.database.schema.table" ) if lineage: - print(f"Upstream entities: {len(lineage.upstreamEdges)}") - print(f"Downstream entities: {len(lineage.downstreamEdges)}") + print(f"Upstream edges: {len(lineage['upstreamEdges'])}") + print(f"Downstream edges: {len(lineage['downstreamEdges'])}") ``` ## API Reference diff --git a/v1.13.x/api-reference/teams-and-users/teams/create.mdx b/v1.13.x/api-reference/teams-and-users/teams/create.mdx index 28f495da5..70ba29f4a 100644 --- a/v1.13.x/api-reference/teams-and-users/teams/create.mdx +++ b/v1.13.x/api-reference/teams-and-users/teams/create.mdx @@ -58,7 +58,7 @@ Create a new team for organizing users and controlling access to data assets. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -81,8 +81,8 @@ Create a new team for organizing users and controlling access to data assets. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -105,20 +105,23 @@ request = CreateTeamRequest( ) team = Teams.create(request) -print(f"Created: {team.fullyQualifiedName}") +print(f"Created: {team.fullyQualifiedName.root}") ``` ```java POST /v1/teams -import static org.openmetadata.sdk.fluent.Teams.*; - -// Create using builder pattern -var team = Teams.builder() - .name("Accounting") - .teamType("Group") - .displayName("Accounting") - .description("Accounting team under Finance") - .parents(List.of("4f87a3ea-d798-4509-8c64-5b11f8a96f89")) - .create(); +import java.util.List; +import java.util.UUID; +import org.openmetadata.schema.api.teams.CreateTeam; + +// client is an initialized OpenMetadataClient. +var request = new CreateTeam() + .withName("Accounting") + .withTeamType(CreateTeam.TeamType.GROUP) + .withDisplayName("Accounting") + .withDescription("Accounting team under Finance") + .withParents(List.of(UUID.fromString("4f87a3ea-d798-4509-8c64-5b11f8a96f89"))); + +var team = client.teams().create(request); ``` ```bash POST /v1/teams diff --git a/v1.13.x/api-reference/teams-and-users/teams/delete.mdx b/v1.13.x/api-reference/teams-and-users/teams/delete.mdx index f3ec3fd9b..d34991d17 100644 --- a/v1.13.x/api-reference/teams-and-users/teams/delete.mdx +++ b/v1.13.x/api-reference/teams-and-users/teams/delete.mdx @@ -51,11 +51,11 @@ Teams.delete( ) # Delete by name -Teams.delete_by_name("Accounting") +Teams.delete(Teams.retrieve_by_name("Accounting").id) # Delete by name with options -Teams.delete_by_name( - "Accounting", +Teams.delete( + Teams.retrieve_by_name("Accounting").id, hard_delete=True ) @@ -64,22 +64,23 @@ Teams.restore("449b5f25-4cbb-42db-8f71-3be2c5cd888a") ``` ```java DELETE /v1/teams/{id} -import static org.openmetadata.sdk.fluent.Teams.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "449b5f25-4cbb-42db-8f71-3be2c5cd888a"; // Soft delete -Teams.delete("449b5f25-4cbb-42db-8f71-3be2c5cd888a").execute(); +client.teams().delete(id); -// Hard delete -Teams.delete("449b5f25-4cbb-42db-8f71-3be2c5cd888a") - .hardDelete() - .execute(); +// Restore +client.teams().restore(id); -// Delete by name -Teams.deleteByName("Accounting") - .execute(); +// Hard delete +client.teams().delete(id, Map.of("hardDelete", "true")); -// Restore -Teams.restore("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); +// Delete by name: look up the ID first +var team = client.teams().getByName("Accounting"); +client.teams().delete(team.getId().toString()); ``` ```bash DELETE /v1/teams/{id} diff --git a/v1.13.x/api-reference/teams-and-users/teams/list.mdx b/v1.13.x/api-reference/teams-and-users/teams/list.mdx index 8839a337a..529d3fee8 100644 --- a/v1.13.x/api-reference/teams-and-users/teams/list.mdx +++ b/v1.13.x/api-reference/teams-and-users/teams/list.mdx @@ -47,49 +47,47 @@ configure( # List first page teams = Teams.list(limit=50) -for team in teams.data: - print(f"{team.fullyQualifiedName} ({team.teamType})") +for team in teams.entities: + print(f"{team.fullyQualifiedName.root} ({team.teamType.value})") # List all with auto-pagination for team in Teams.list_all(): - print(f"{team.fullyQualifiedName}") + print(f"{team.fullyQualifiedName.root}") # Filter by parent team teams = Teams.list( - parentTeam="Finance", + filters={"parentTeam": "Finance"}, fields=["users", "parents", "policies"], limit=50 ) -for team in teams.data: - print(f"{team.fullyQualifiedName}") +for team in teams.entities: + print(f"{team.fullyQualifiedName.root}") if team.users: - print(f" Users: {[u.name for u in team.users]}") + print(f" Users: {[u.name for u in team.users.root]}") if team.parents: - print(f" Parents: {[p.name for p in team.parents]}") + print(f" Parents: {[p.name for p in team.parents.root]}") ``` ```java GET /v1/teams -import static org.openmetadata.sdk.fluent.Teams.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Teams.list() - .limit(50) - .execute(); - -for (var team : result.getData()) { - System.out.println(team.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.teams().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by parent team with fields -var result = Teams.list() - .parentTeam("Finance") - .fields("users", "parents", "policies") - .limit(50) - .execute(); - -for (var team : result.getData()) { - System.out.println(team.getFullyQualifiedName()); +var filtered = new ListParams() + .addFilter("parentTeam", "Finance") + .setFields("users,parents,policies") + .setLimit(50); +var filteredPage = client.teams().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` diff --git a/v1.13.x/api-reference/teams-and-users/teams/retrieve.mdx b/v1.13.x/api-reference/teams-and-users/teams/retrieve.mdx index dcb6c1464..afa2a06c2 100644 --- a/v1.13.x/api-reference/teams-and-users/teams/retrieve.mdx +++ b/v1.13.x/api-reference/teams-and-users/teams/retrieve.mdx @@ -16,7 +16,7 @@ Get a single team by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `users,parents,children,policies,domains,owners`). + Comma-separated list of fields to include, for example `users,parents,children,policies,domains,owners`. @@ -28,7 +28,7 @@ Get a single team by its unique ID or fully qualified name. Use `GET /v1/teams/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the team (e.g., `Accounting`). + Fully qualified name of the team, for example `Accounting`. @@ -51,7 +51,7 @@ configure( # Get by ID team = Teams.retrieve("449b5f25-4cbb-42db-8f71-3be2c5cd888a") -print(f"{team.fullyQualifiedName}: {team.teamType}") +print(f"{team.fullyQualifiedName.root}: {team.teamType.value}") # Get by ID with fields team = Teams.retrieve( @@ -70,25 +70,21 @@ team = Teams.retrieve_by_name( ``` ```java GET /v1/teams/{id} -import static org.openmetadata.sdk.fluent.Teams.*; - -// Get by ID -var team = Teams.retrieve("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); +// client is an initialized OpenMetadataClient. +var team = client.teams().get("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); // Get by ID with fields -var team = Teams.retrieve( +var teamWithFields = client.teams().get( "449b5f25-4cbb-42db-8f71-3be2c5cd888a", - "users,parents,policies" -); + "users,parents,policies"); // Get by fully qualified name -var team = Teams.retrieveByName("Accounting"); +var teamByName = client.teams().getByName("Accounting"); // Get by name with fields -var team = Teams.retrieveByName( +var teamByNameWithFields = client.teams().getByName( "Accounting", - "users,parents,children" -); + "users,parents,children"); ``` ```bash GET /v1/teams/{id} diff --git a/v1.13.x/api-reference/teams-and-users/teams/update.mdx b/v1.13.x/api-reference/teams-and-users/teams/update.mdx index 23bb6b1c3..20b1f332c 100644 --- a/v1.13.x/api-reference/teams-and-users/teams/update.mdx +++ b/v1.13.x/api-reference/teams-and-users/teams/update.mdx @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -63,8 +63,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -83,16 +83,16 @@ team.description = "Updated: Accounting team handling all financial reporting" team.displayName = "Accounting & Reporting" updated = Teams.update(team) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/teams/{id} -import static org.openmetadata.sdk.fluent.Teams.*; - -// Retrieve, modify, and update -var team = Teams.retrieve("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); +// client is an initialized OpenMetadataClient. +var teamId = "449b5f25-4cbb-42db-8f71-3be2c5cd888a"; +var team = client.teams().get(teamId); team.setDescription("Updated: Accounting team handling all financial reporting"); -var updated = Teams.update(team); + +var updated = client.teams().update(teamId, team); ``` ```bash PATCH /v1/teams/{id} diff --git a/v1.13.x/api-reference/teams-and-users/teams/versions.mdx b/v1.13.x/api-reference/teams-and-users/teams/versions.mdx index 311e58057..b82b6a399 100644 --- a/v1.13.x/api-reference/teams-and-users/teams/versions.mdx +++ b/v1.13.x/api-reference/teams-and-users/teams/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/teams/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/teams/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Teams @@ -40,31 +42,29 @@ configure( # List all versions versions = Teams.get_versions("449b5f25-4cbb-42db-8f71-3be2c5cd888a") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version team_v1 = Teams.get_specific_version( "449b5f25-4cbb-42db-8f71-3be2c5cd888a", "0.1" ) -print(f"Original name: {team_v1.name}") +print(f"Original name: {team_v1.name.root}") ``` ```java GET /v1/teams/{id}/versions -import static org.openmetadata.sdk.fluent.Teams.*; +// client is an initialized OpenMetadataClient. +var id = "449b5f25-4cbb-42db-8f71-3be2c5cd888a"; // List all versions -var history = Teams.getVersions("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); - +var history = client.teams().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Teams.getSpecificVersion( - "449b5f25-4cbb-42db-8f71-3be2c5cd888a", - 0.1 -); +var v1 = client.teams().getVersion(id, 0.1); System.out.println("Name: " + v1.getName()); ``` diff --git a/v1.13.x/api-reference/teams-and-users/users/create.mdx b/v1.13.x/api-reference/teams-and-users/users/create.mdx index 96f8d6873..0ceadf2c3 100644 --- a/v1.13.x/api-reference/teams-and-users/users/create.mdx +++ b/v1.13.x/api-reference/teams-and-users/users/create.mdx @@ -47,8 +47,8 @@ Create a new user in your organization. Array of persona references to assign to the user. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -60,7 +60,7 @@ Create a new user in your organization. - Timezone of the user (e.g., `America/New_York`). + Timezone of the user, for example `America/New_York`. @@ -86,19 +86,20 @@ request = CreateUserRequest( ) user = Users.create(request) -print(f"Created: {user.fullyQualifiedName}") +print(f"Created: {user.fullyQualifiedName.root}") ``` ```java POST /v1/users -import static org.openmetadata.sdk.fluent.Users.*; - -// Create using builder pattern -var user = Users.builder() - .name("aaron_johnson0") - .displayName("Aaron Johnson") - .email("aaron_johnson0@gmail.com") - .description("Data analyst in the Sales team") - .create(); +import org.openmetadata.schema.api.teams.CreateUser; + +// client is an initialized OpenMetadataClient. +var request = new CreateUser() + .withName("aaron_johnson0") + .withDisplayName("Aaron Johnson") + .withEmail("aaron_johnson0@gmail.com") + .withDescription("Data analyst in the Sales team"); + +var user = client.users().create(request); ``` ```bash POST /v1/users diff --git a/v1.13.x/api-reference/teams-and-users/users/delete.mdx b/v1.13.x/api-reference/teams-and-users/users/delete.mdx index f794ffadf..802f00d03 100644 --- a/v1.13.x/api-reference/teams-and-users/users/delete.mdx +++ b/v1.13.x/api-reference/teams-and-users/users/delete.mdx @@ -28,7 +28,7 @@ Delete a user by ID or fully qualified name. Supports soft delete (default), har Use `DELETE /v1/users/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the user (e.g., `aaron_johnson0`). + Fully qualified name of the user, for example `aaron_johnson0`. @@ -67,11 +67,11 @@ Users.delete( ) # Delete by name -Users.delete_by_name("aaron_johnson0") +Users.delete(Users.retrieve_by_name("aaron_johnson0").id) # Delete by name with options -Users.delete_by_name( - "aaron_johnson0", +Users.delete( + Users.retrieve_by_name("aaron_johnson0").id, hard_delete=True ) @@ -80,22 +80,23 @@ Users.restore("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") ``` ```java DELETE /v1/users/{id} -import static org.openmetadata.sdk.fluent.Users.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "77655e6e-ad33-49da-bbca-db4ba4d4e2cd"; // Soft delete -Users.delete("77655e6e-ad33-49da-bbca-db4ba4d4e2cd").execute(); +client.users().delete(id); -// Hard delete -Users.delete("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") - .hardDelete() - .execute(); +// Restore +client.users().restore(id); -// Delete by name -Users.deleteByName("aaron_johnson0") - .execute(); +// Hard delete +client.users().delete(id, Map.of("hardDelete", "true")); -// Restore -Users.restore("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); +// Delete by name: look up the ID first +var user = client.users().getByName("aaron_johnson0"); +client.users().delete(user.getId().toString()); ``` ```bash DELETE /v1/users/{id} diff --git a/v1.13.x/api-reference/teams-and-users/users/list.mdx b/v1.13.x/api-reference/teams-and-users/users/list.mdx index d222cab92..6a8a7d730 100644 --- a/v1.13.x/api-reference/teams-and-users/users/list.mdx +++ b/v1.13.x/api-reference/teams-and-users/users/list.mdx @@ -55,52 +55,50 @@ configure( # List first page users = Users.list(limit=50) -for user in users.data: - print(f"{user.fullyQualifiedName}") +for user in users.entities: + print(f"{user.fullyQualifiedName.root}") # List all with auto-pagination for user in Users.list_all(): - print(f"{user.fullyQualifiedName}") + print(f"{user.fullyQualifiedName.root}") # Filter by team with fields users = Users.list( - team="Sales", + filters={"team": "Sales"}, fields=["teams", "roles", "domains"], limit=50 ) -for user in users.data: - print(f"{user.fullyQualifiedName}") +for user in users.entities: + print(f"{user.fullyQualifiedName.root}") if user.teams: - print(f" Teams: {[t.name for t in user.teams]}") + print(f" Teams: {[t.name for t in user.teams.root]}") if user.roles: - print(f" Roles: {[r.name for r in user.roles]}") + print(f" Roles: {[r.name for r in user.roles.root]}") # Filter bot accounts -bots = Users.list(isBot=True, limit=50) +bots = Users.list(filters={"isBot": "true"}, limit=50) ``` ```java GET /v1/users -import static org.openmetadata.sdk.fluent.Users.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Users.list() - .limit(50) - .execute(); - -for (var user : result.getData()) { - System.out.println(user.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.users().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by team with fields -var result = Users.list() - .team("Sales") - .fields("teams", "roles", "domains") - .limit(50) - .execute(); - -for (var user : result.getData()) { - System.out.println(user.getFullyQualifiedName()); +var filtered = new ListParams() + .addFilter("team", "Sales") + .setFields("teams,roles,domains") + .setLimit(50); +var filteredPage = client.users().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` diff --git a/v1.13.x/api-reference/teams-and-users/users/retrieve.mdx b/v1.13.x/api-reference/teams-and-users/users/retrieve.mdx index 3cac49182..5e8ec215e 100644 --- a/v1.13.x/api-reference/teams-and-users/users/retrieve.mdx +++ b/v1.13.x/api-reference/teams-and-users/users/retrieve.mdx @@ -16,7 +16,7 @@ Get a single user by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `teams,roles,personas,domains,follows,owns`). + Comma-separated list of fields to include, for example `teams,roles,personas,domains,follows,owns`. @@ -28,7 +28,7 @@ Get a single user by its unique ID or fully qualified name. Use `GET /v1/users/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the user (e.g., `aaron_johnson0`). + Fully qualified name of the user, for example `aaron_johnson0`. @@ -51,7 +51,7 @@ configure( # Get by ID user = Users.retrieve("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") -print(f"{user.fullyQualifiedName}: {user.email}") +print(f"{user.fullyQualifiedName.root}: {user.email.root}") # Get by ID with fields user = Users.retrieve( @@ -70,25 +70,21 @@ user = Users.retrieve_by_name( ``` ```java GET /v1/users/{id} -import static org.openmetadata.sdk.fluent.Users.*; - -// Get by ID -var user = Users.retrieve("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); +// client is an initialized OpenMetadataClient. +var user = client.users().get("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); // Get by ID with fields -var user = Users.retrieve( +var userWithFields = client.users().get( "77655e6e-ad33-49da-bbca-db4ba4d4e2cd", - "teams,roles,domains" -); + "teams,roles,domains"); // Get by fully qualified name -var user = Users.retrieveByName("aaron_johnson0"); +var userByName = client.users().getByName("aaron_johnson0"); // Get by name with fields -var user = Users.retrieveByName( +var userByNameWithFields = client.users().getByName( "aaron_johnson0", - "teams,roles,domains" -); + "teams,roles,domains"); ``` ```bash GET /v1/users/{id} diff --git a/v1.13.x/api-reference/teams-and-users/users/update.mdx b/v1.13.x/api-reference/teams-and-users/users/update.mdx index 2afbeade4..7c8cfb6c3 100644 --- a/v1.13.x/api-reference/teams-and-users/users/update.mdx +++ b/v1.13.x/api-reference/teams-and-users/users/update.mdx @@ -20,7 +20,7 @@ Update a user's properties using JSON Merge Patch. You can update by ID or by fu Use `PATCH /v1/users/name/{fqn}` to update by fully qualified name. - Fully qualified name of the user (e.g., `aaron_johnson0`). + Fully qualified name of the user, for example `aaron_johnson0`. ## Body Parameters @@ -71,8 +71,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -95,16 +95,16 @@ user.description = "Senior data analyst in the Sales team" user.displayName = "Aaron M. Johnson" updated = Users.update(user) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/users/{id} -import static org.openmetadata.sdk.fluent.Users.*; - -// Retrieve, modify, and update -var user = Users.retrieve("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); +// client is an initialized OpenMetadataClient. +var userId = "77655e6e-ad33-49da-bbca-db4ba4d4e2cd"; +var user = client.users().get(userId); user.setDescription("Senior data analyst in the Sales team"); -var updated = Users.update(user); + +var updated = client.users().update(userId, user); ``` ```bash PATCH /v1/users/{id} diff --git a/v1.13.x/api-reference/teams-and-users/users/versions.mdx b/v1.13.x/api-reference/teams-and-users/users/versions.mdx index 7200919f2..0e1ebf62d 100644 --- a/v1.13.x/api-reference/teams-and-users/users/versions.mdx +++ b/v1.13.x/api-reference/teams-and-users/users/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/users/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/users/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Users @@ -40,7 +42,8 @@ configure( # List all versions versions = Users.get_versions("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version user_v1 = Users.get_specific_version( @@ -51,20 +54,17 @@ print(f"Original display name: {user_v1.displayName}") ``` ```java GET /v1/users/{id}/versions -import static org.openmetadata.sdk.fluent.Users.*; +// client is an initialized OpenMetadataClient. +var id = "77655e6e-ad33-49da-bbca-db4ba4d4e2cd"; // List all versions -var history = Users.getVersions("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); - +var history = client.users().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Users.getSpecificVersion( - "77655e6e-ad33-49da-bbca-db4ba4d4e2cd", - 0.1 -); +var v1 = client.users().getVersion(id, 0.1); System.out.println("Display Name: " + v1.getDisplayName()); ``` diff --git a/v1.13.x/connectors/ingestion/deployment.mdx b/v1.13.x/connectors/ingestion/deployment.mdx index 033484b9b..8cb33110d 100644 --- a/v1.13.x/connectors/ingestion/deployment.mdx +++ b/v1.13.x/connectors/ingestion/deployment.mdx @@ -277,14 +277,15 @@ it will be the [AirflowRESTClient](https://github.com/open-metadata/OpenMetadata First, let's see what it is needed to instantiate the Airflow REST Client: ```java -public AirflowRESTClient(AirflowConfiguration airflowConfig) { - super( - airflowConfig.getUsername(), - airflowConfig.getPassword(), - airflowConfig.getApiEndpoint(), - airflowConfig.getHostIp(), - airflowConfig.getTimeout()); - } +public AirflowRESTClient(PipelineServiceClientConfiguration config) throws KeyStoreException { + super(config); + ... + this.username = getStringParam(params, USERNAME_KEY); + this.password = getStringParam(params, PASSWORD_KEY); + ... + this.serviceURL = validateServiceURL(config.getApiEndpoint()); + ... +} ``` If we focus on the important properties here, we can see: diff --git a/v1.13.x/deployment/secrets-manager/how-to-add-a-new-implementation.mdx b/v1.13.x/deployment/secrets-manager/how-to-add-a-new-implementation.mdx index 6f52295b8..1ae5ab4c0 100644 --- a/v1.13.x/deployment/secrets-manager/how-to-add-a-new-implementation.mdx +++ b/v1.13.x/deployment/secrets-manager/how-to-add-a-new-implementation.mdx @@ -32,22 +32,43 @@ You can find [this](https://github.com/open-metadata/OpenMetadata/blob/main/open Once we have updated the JSON Schema, we can start implementing our Secrets Manager, extending the `ExternalSecretsManager.java` abstract class located [here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-service/src/main/java/org/openmetadata/service/secrets/ExternalSecretsManager.java). For example: ```java -public abstract class AwesomeSecretsManager extends ExternalSecretsManager { +public class AwesomeSecretsManager extends ExternalSecretsManager { - protected AwesomeSecretsManager(String clusterPrefix) { - super(SecretsManagerProvider.AWESOME_SM, clusterPrefix); + private static AwesomeSecretsManager instance = null; + + private AwesomeSecretsManager(SecretsConfig secretsConfig) { + super(SecretsManagerProvider.AWESOME_SM, secretsConfig); } + @Override void storeSecret(String secretName, String secretValue) { // your implementation } + + @Override void updateSecret(String secretName, String secretValue) { // your implementation } + @Override String getSecret(String secretName) { // your implementation } + + @Override + protected void deleteSecretInternal(String secretName) { + // your implementation + } + + @Override + protected boolean isNotFoundException(Exception exception) { + // your implementation + } + + public static AwesomeSecretsManager getInstance(SecretsConfig secretsConfig) { + if (instance == null) instance = new AwesomeSecretsManager(secretsConfig); + return instance; + } } ``` @@ -55,8 +76,7 @@ After this, we can update `SecretsManagerFactory.java` which is a factory class. ```java ... - case AWESOME_SM: - return AwesomeSecretsManager.getInstance(config, clusterName); + case AWESOME_SM -> secretsManager = AwesomeSecretsManager.getInstance(secretsConfig); ... ``` diff --git a/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx b/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx index f69aefa94..cfd5eff21 100644 --- a/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx +++ b/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx @@ -12,7 +12,8 @@ For large datasets that don't fit in memory, validate data in chunks: ```python import pandas as pd -from metadata.sdk.data_quality.dataframes.dataframe_validator import DataFrameValidator, ValidationResult +from metadata.sdk.data_quality.dataframes.dataframe_validator import DataFrameValidator +from metadata.sdk.data_quality.dataframes.validation_results import ValidationResult validator = DataFrameValidator() validator.add_openmetadata_table_tests("Postgres.warehouse.staging.transactions") @@ -144,7 +145,7 @@ print(f"Validation {'succeeded' if result.success else 'failed'}") As of version 1.11.0.0 of the SDK, DataFrameValidator supports only one failure mode: short circuit. ```python -from metadata.sdk.data_quality.dataframes import FailureMode +from metadata.sdk.data_quality.dataframes.validation_results import FailureMode # SHORT_CIRCUIT (default): Stop on first test failure result = validator.validate(df, mode=FailureMode.SHORT_CIRCUIT) @@ -181,7 +182,7 @@ for test_case, test_result in result.test_cases_and_results: ### Merging Results from Multiple Chunks ```python -from metadata.sdk.data_quality.dataframes import ValidationResult +from metadata.sdk.data_quality.dataframes.validation_results import ValidationResult results = [] diff --git a/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx b/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx index 7c79a310a..40c21f3b6 100644 --- a/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx +++ b/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx @@ -79,7 +79,7 @@ if result.success: else: print("✗ Validation failed") for test_case, test_result in result.test_cases_and_results: - if test_result.testCaseStatus != "Success": + if test_result.testCaseStatus.value != "Success": print(f" - {test_case.name.root}: {test_result.result}") ``` diff --git a/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx b/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx index 6e6466851..8893defc3 100644 --- a/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx +++ b/v1.13.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx @@ -406,7 +406,7 @@ If you experience connection timeouts, verify: If you encounter import errors: -```python +```text ModuleNotFoundError: No module named 'metadata' ``` diff --git a/v1.13.x/sdk/ai-sdk.mdx b/v1.13.x/sdk/ai-sdk.mdx index f095a11ce..fd1f9981b 100644 --- a/v1.13.x/sdk/ai-sdk.mdx +++ b/v1.13.x/sdk/ai-sdk.mdx @@ -92,7 +92,7 @@ const client = new AISdk({ ```java Java import io.openmetadata.ai.AISdk; -AISdk client = new AISdk.Builder() +AISdk client = AISdk.builder() .host("https://your-openmetadata-instance.com") .token("your-bot-jwt-token") .build(); @@ -144,7 +144,7 @@ console.log(`Created persona: ${persona.name}`); import io.openmetadata.ai.models.CreatePersonaRequest; import io.openmetadata.ai.models.PersonaInfo; -CreatePersonaRequest request = new CreatePersonaRequest.Builder() +CreatePersonaRequest request = CreatePersonaRequest.builder() .name("DataAnalyst") .description("A meticulous data analyst focused on data quality") .prompt("You are an expert data analyst working with OpenMetadata. " @@ -153,7 +153,7 @@ CreatePersonaRequest request = new CreatePersonaRequest.Builder() .displayName("Data Analyst") .build(); -PersonaInfo persona = client.createPersona(request); +PersonaInfo persona = client.personas().create(request); System.out.println("Created persona: " + persona.getName()); ``` @@ -187,7 +187,10 @@ for (const persona of personas) { ``` ```java Java -List personas = client.listPersonas(); +import io.openmetadata.ai.models.PersonaInfo; +import java.util.List; + +List personas = client.personas().list(); for (PersonaInfo persona : personas) { System.out.println(persona.getName() + ": " + persona.getDescription()); } @@ -248,23 +251,24 @@ console.log(`Created agent: ${agent.name}`); ``` ```java Java -import io.openmetadata.ai.models.CreateAgentRequest; import io.openmetadata.ai.models.AgentInfo; +import io.openmetadata.ai.models.CreateAgentRequest; +import java.util.List; -CreateAgentRequest request = new CreateAgentRequest.Builder() +// Pass the builder to create(); don't call build() +CreateAgentRequest.Builder request = CreateAgentRequest.builder() .name("DataQualityPlannerAgent") .description("Analyzes tables and recommends data quality tests") .persona("DataAnalyst") .displayName("Data Quality Planner") .apiEnabled(true) - .abilities(List.of( + .skills(List.of( "search_metadata", "get_entity_details", "get_entity_lineage" - )) - .build(); + )); -AgentInfo agent = client.createAgent(request); +AgentInfo agent = client.agents().create(request); System.out.println("Created agent: " + agent.getName()); ``` @@ -279,7 +283,7 @@ System.out.println("Created agent: " + agent.getName()); | `persona` | string | Yes | Name of an existing persona | | `display_name` | string | No | Human-readable name (defaults to `name`) | | `api_enabled` | boolean | No | Must be `true` for SDK invocation (default: `false`) | -| `abilities` | array | No | Allowed MCP tool names (all tools if omitted) | +| `abilities` | array | No | Allowed MCP tool names (all tools if omitted). In the Java SDK, the builder method is `skills`. | | `prompt` | string | No | Additional system prompt appended to persona's base prompt | | `provider` | string | No | LLM provider: `openai`, `anthropic`, `azure_openai` (default: `openai`) | | `bot_name` | string | No | OpenMetadata bot for metadata operations | @@ -306,7 +310,10 @@ for (const agent of agents) { ``` ```java Java -List agents = client.listAgents(); +import io.openmetadata.ai.models.AgentInfo; +import java.util.List; + +List agents = client.agents().list(); for (AgentInfo agent : agents) { System.out.println(agent.getName() + ": " + agent.getDescription()); } @@ -341,8 +348,10 @@ console.log(`Tools used: ${response.toolsUsed}`); ``` ```java Java +import io.openmetadata.ai.models.InvokeResponse; + InvokeResponse response = client.agent("DataQualityPlannerAgent") - .call("What data quality tests should I add for the customers table?"); + .invoke("What data quality tests should I add for the customers table?"); System.out.println(response.getResponse()); ``` @@ -398,12 +407,12 @@ for await (const event of client.agent('DataQualityPlannerAgent').stream( ```java Java client.agent("DataQualityPlannerAgent") - .stream("Analyze the orders table") - .forEach(event -> { + .stream("Analyze the orders table", event -> { switch (event.getType()) { - case "content" -> System.out.print(event.getContent()); - case "tool_use" -> System.out.println("\n[Using: " + event.getToolName() + "]"); - case "end" -> System.out.println("\nDone!"); + case CONTENT -> System.out.print(event.getContent()); + case TOOL_USE -> System.out.println("\n[Using: " + event.getToolName() + "]"); + case END -> System.out.println("\nDone!"); + default -> { } } }); ``` diff --git a/v1.13.x/sdk/go.mdx b/v1.13.x/sdk/go.mdx index 0b60e1b04..4cb52c437 100644 --- a/v1.13.x/sdk/go.mdx +++ b/v1.13.x/sdk/go.mdx @@ -25,20 +25,32 @@ go get github.com/open-metadata/openmetadata-sdk/openmetadata-go-client ## Create a Client -To interact with the OpenMetadata API, create a `Client` by providing the server URL and a JWT token for authentication: +To interact with the OpenMetadata API, create a `Client` by providing the server URL and a JWT token for authentication. Pass the server address without the `/api` suffix (for example `http://localhost:8585`). The client adds `/api/v1` itself. ```go package main import ( + "context" + "fmt" + "log" + "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" ) func main() { + ctx := context.Background() client := ometa.NewClient( "http://localhost:8585", ometa.WithToken(""), ) + + for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Name) + } } ``` @@ -56,6 +68,8 @@ You can customize the client behavior using functional options: Requests that return HTTP `429` (Too Many Requests) or `504` (Gateway Timeout) are automatically retried. ```go +import "time" + client := ometa.NewClient( "http://localhost:8585", ometa.WithToken(""), @@ -92,6 +106,8 @@ Every service provides the following methods: The `List` method returns a Go iterator that handles pagination automatically: ```go +ctx := context.Background() + for table, err := range client.Tables.List(ctx, nil) { if err != nil { log.Fatal(err) @@ -106,10 +122,10 @@ Retrieve a single entity by UUID or by Fully Qualified Name: ```go // By ID -table, err := client.Tables.GetByID(ctx, "", nil) +tableByID, err := client.Tables.GetByID(ctx, "", nil) // By Fully Qualified Name -table, err := client.Tables.GetByName(ctx, "sample_data.ecommerce_db.shopify.dim_customer", nil) +tableByName, err := client.Tables.GetByName(ctx, "sample_data.ecommerce_db.shopify.dim_customer", nil) ``` ### Create an Entity @@ -161,7 +177,7 @@ Delete by UUID or by Fully Qualified Name: err := client.Tables.Delete(ctx, "", nil) // By Fully Qualified Name with hard delete -err := client.Tables.DeleteByName(ctx, "sample_data.ecommerce_db.shopify.my_table", +err = client.Tables.DeleteByName(ctx, "sample_data.ecommerce_db.shopify.my_table", &ometa.DeleteTable1Params{HardDelete: ometa.Bool(true)}, ) ``` @@ -181,8 +197,9 @@ table, err := client.Tables.GetVersion(ctx, "", "0.2") ### Restore a Soft-Deleted Entity ```go -table, err := client.Tables.Restore(ctx, &ometa.RestoreEntity{ - Id: ometa.Str(""), +// table is a *ometa.Table you retrieved earlier +restored, err := client.Tables.Restore(ctx, &ometa.RestoreEntity{ + Id: table.Id, }) ``` diff --git a/v1.13.x/sdk/java.mdx b/v1.13.x/sdk/java.mdx index 2f32375ff..411309f38 100644 --- a/v1.13.x/sdk/java.mdx +++ b/v1.13.x/sdk/java.mdx @@ -24,204 +24,148 @@ You can add the below Maven Dependency for the OpenMetadata Java SDK. ``` -## Establish OpenMetadata Server Connection +## Connect to the OpenMetadata Server -To create OpenMetadata Gateway, you will need to establish a connection with *OpenMetadata Server*. The following -inputs will be needed for the same. -* Host Port: The url on which your instance of OpenMetadata is up and running. -* ApiVersion: The value will be "v1". -* Auth Provider: Provide the auth provider with which you need to configure. -* Security Config: Provide the config for the selected auth provider. +To connect to your OpenMetadata server, you need: -```java -OpenMetadataConnection server = new OpenMetadataConnection(); -server.setHostPort("http://localhost:{port}}/api"); -server.setApiVersion("v1"); -server.setAuthProvider(OpenMetadataConnection.AuthProvider.{auth_provider}); -server.setSecurityConfig({security_client_config}); -``` - -## Create OpenMetadata Gateway - -Once the connection details are provided, you can create an OpenMetadata Gateway -using the following piece of code. +* Server URL: The URL where your OpenMetadata instance is running, ending in `/api`. For example, `http://localhost:8585/api`. +* Access token: A JSON Web Token (JWT) for a user or bot. See [Authentication](/v1.13.x/api-reference/authentication) to learn how to get one. ```java -// OpenMetadata Gateway -OpenMetadata openMetadataGateway = new OpenMetadata(server); -``` +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -## Use Java SDK without Authentication -To use the Java SDK without any authentication, you can use `NoOpAuthenticationProvider.java`. \ +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .build(); -```java -NoOpAuthenticationProvider noOpAuthenticationProvider = new NoOpAuthenticationProvider(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` -Establish the [OpenMetadata Server Connection](#establish-openmetadata-server-connection) and provide `noOpAuthenticationProvider` in the config. +Tune the connection with these options. Timeouts are in milliseconds, and `header` adds a custom header to every request: ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.NO_AUTH); +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .connectTimeout(10000) + .readTimeout(30000) + .header("X-Request-Source", "my-app") + .build(); ``` -## Use Java SDK with Authentication. +## Authenticate with a JWT Token -The OpenMetadata Java SDK supports several auth providers: -* [Google](#google) -* [Okta](#okta) -* [Auth0](#auth0) -* [Azure](#azure) -* [OpenMetadata](#openmetadata) +The Java SDK authenticates with a JWT access token that you pass to `accessToken(...)`. This is the same for every sign-in method on your OpenMetadata server, including Google, Okta, Auth0, Azure, and custom OpenID Connect (OIDC). Generate a bot token or a personal access token in OpenMetadata and use it here. -Apart from the above mentioned auth providers, OpenMetadata Java SDK also supports [Custom OIDC](#custom-oidc). +If your server doesn't require authentication, leave out `accessToken(...)`. -### Google -To set up Google as the auth provider, the following details are required: -* Secret Key: Pass the JSON file generated in [Create Service Account](/v1.13.x/deployment/security/google) as the secretKey. +## Use the Fluent API -```java -GoogleSSOClientConfig googleSSOClientConfig = new GoogleSSOClientConfig(); -ssoConfig.setAudience("https://www.googleapis.com/oauth2/v4/token"); -ssoConfig.setSecretKey("{secret_key.json}"); -``` +The fluent classes, such as `Tables`, `Users`, and `Teams`, work with a default client. Register your client once with `OM.init`, and the fluent classes use it: -Provide the Google config while creating the [server connection](#establish-openmetadata-server-connection). ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.GOOGLE); -server.setSecurityConfig(googleSSOClientConfig); +import org.openmetadata.sdk.OM; +import org.openmetadata.sdk.fluent.Tables; -``` +OM.init(client); -### Okta -To set up Okta as the auth provider, the following details should be provided: -* Client ID: Provide the client ID for the service application -* Org URL: It is the same as the ISSUER_URL with v1/token. It is recommended to use a separate authorization server for different applications, rather than using the default authorization server. -* Private Key: Use the Public/Private Key Pair that was generated while [Creating the Service Application](/v1.13.x/deployment/security/okta#okta-sso). When copy-pasting the keys ensure that there are no additional codes and that it is a JSON compatible string. -* Email: Enter the email address -* Scopes: Add the details of the scope created in the Authorization Server. Enter the name of the default scope created. +// Find a table by its fully qualified name +var table = Tables.findByName("mysql-prod.employees.public.employees") + .includeOwners() + .includeTags() + .fetch() + .get(); -```java -OktaSSOClientConfig oktaSSOClientConfig = new OktaSSOClientConfig(); -oktaSSOClientConfig.setClientId("{client_id}"); -oktaSSOClientConfig.setOrgURL("{org_url}/v1/token"); -oktaSSOClientConfig.setPrivateKey("{public/private keypair}"); -oktaSSOClientConfig.setEmail("{email}"); -oktaSSOClientConfig.setScopes({scope_list}); +// Update its description +Tables.findByName("mysql-prod.employees.public.employees") + .fetch() + .withDescription("Updated description") + .save(); ``` -Provide the Okta config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OKTA); -server.setSecurityConfig(oktaSSOClientConfig); -``` +## Use the Service Clients -### Auth0 -To set up Auth0 as the auth provider, the following details are required: -* Client ID: Provide the client ID for the service application -* Secret Key: Provide the client secret. -* Domain: Provide the Auth0 domain. For example `test.us.auth0.com` +Every entity type has a service on the client, such as `client.tables()`, `client.users()`, and `client.dashboards()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. Below are some examples: ```java -Auth0SSOClientConfig auth0SSOClientConfig = new Auth0SSOClientConfig(); -auth0SSOClientConfig.setClientId("{client_id}"); -auth0SSOClientConfig.setSecretKey("{secret_key}"); -auth0SSOClientConfig.setDomain("{domain}"); -``` -Provide the Auth0 config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AUTH_0); -server.setSecurityConfig(auth0SSOClientConfig); -``` +import org.openmetadata.sdk.models.ListParams; -### Azure -To set up Azure as the auth provider, the following details should be provided: -* Client ID: The Application (Client) ID is displayed in the Overview section of the registered application. -* Client Secret: The clientSecret can be accessed from the Certificates & secret section of the application. -* Authority: Use your Microsoft Entra tenant authority. See [Microsoft's OpenID Connect documentation](https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc) for the endpoint format. -* Scopes: Add the details of the scope created. +// Tables +var tables = client.tables().list(new ListParams().setLimit(10)); +for (var table : tables.getData()) { + System.out.println(table.getFullyQualifiedName()); +} -```java -AzureSSOClientConfig azureSSOClientConfig = new AzureSSOClientConfig(); -azureSSOClientConfig.setClientId("{client_id}"); -azureSSOClientConfig.setClientSecret("{client_secret}"); -azureSSOClientConfig.setAuthority("{authority}"); -azureSSOClientConfig.setScopes({scope_list}); -``` -Provide the Azure config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AZURE); -server.setSecurityConfig(azureSSOClientConfig); +// Users +var users = client.users().list(new ListParams().setLimit(10)); + +// Dashboards +var dashboards = client.dashboards().list(new ListParams().setLimit(10)); ``` -### OpenMetadata -To set up OpenMetadata as the auth provider, the following details should be provided: -* JWT Token: Provide the JWT Token. For example `eyJraWQiOiJHYjM4OWEtOWY3Ni1nZGpzLWE5Mmo....XN0aW9uLWJvdEBvcGVubWV0YWRhdGEub3JnIn0.Ku_FHGIS3Id3ARusMaXZDYKcq...Ztap9KDU7nZilNT2Bq-o75aIsgKKmtSuVdBTzpFK8aLGLmRp_8J007t-kpcjIW7Qf0l4...dGb0QqhoZin0JA` +The following examples show how to call an API: + +* Create a table ```java -OpenMetadataJWTClientConfig openMetadataJWTClientConfig = new OpenMetadataJWTClientConfig(); -openMetadataJWTClientConfig.setJwtToken("{jwt_token}"); -``` -Provide the OpenMetadata config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OPENMETADATA); -server.setSecurityConfig(openMetadataJWTClientConfig); -``` +import java.util.List; +import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; -### Custom OIDC -To set up Custom auth provider. The following details are required: -* Client ID: Provide the client ID of the preferred auth provider -* Client Secret: Provide the client secret of your preferred auth provider -* Token Endpoint: Provide the token endpoint of your preferred auth provider +CreateTable request = new CreateTable() + .withName("orders") + .withDatabaseSchema("mysql-prod.employees.public") + .withDescription("Orders placed by customers") + .withColumns(List.of( + new Column() + .withName("order_id") + .withDataType(ColumnDataType.BIGINT) + .withDescription("Primary key"), + new Column() + .withName("status") + .withDataType(ColumnDataType.VARCHAR) + .withDataLength(50))); -```java -CustomOIDCSSOClientConfig customOIDCSSOClientConfig = new CustomOIDCSSOClientConfig(); -config.setClientId("{client_id}"); -config.setSecretKey("{client_secret}"); -config.setTokenEndpoint("{token_endpoint}"); +var table = client.tables().create(request); ``` -Provide the custom auth provider config while creating the [server connection](#establish-openmetadata-server-connection). +* Get a table by fully qualified name + ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.CUSTOM_OIDC); -server.setSecurityConfig(customOIDCSSOClientConfig); +var table = client.tables().getByName("mysql-prod.employees.public.employees", "columns,owners"); ``` -## How to Use APIs Using the Java SDK -You can use an API from the [OpenMetadata Gateway](#create-openmetadata-gateway). -Using OpenMetadata Gateway, you will need to build the client by providing the `class` of the respected API. -Below are some examples: +* Search + ```java -// Dashboards API -DashboardsApi dashboardApi = openMetadataGateway.buildClient(DashboardsApi.class); +String response = client.search() + .query("customer") + .index("table_search_index") + .size(10) + .execute(); +``` -// Tables API -TablesApi tablesApiClient = openMetadataGateway.buildClient(TablesApi.class); +The search call returns the raw JSON response from the server as a string. -// Users API -UsersApi usersApi = openMetadataGateway.buildClient(UsersApi.class); +## Handle Errors -// Locations API -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -``` +When the server returns an error, the SDK throws an `OpenMetadataException`. Use `getStatusCode()` to see which error it was: -Please refer to the examples to access an API: -* Tables API ```java -TablesApi tablesApi = openMetadataGateway.buildClient(TablesApi.class); -tablesApi.addLocationToTable("{table_id}", "{location_id}"); -``` -* Location API -```java -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -CreateLocation createLocation = new CreateLocation(); -Location location = locationsApi.createLocation(createLocation); -``` +import org.openmetadata.sdk.exceptions.OpenMetadataException; -* Elastic Search API -```java -ElasticSearchApi esApi = openMetadataGateway.buildClient(ElasticSearchApi.class); -Response response = esApi.searchEntitiesWithQuery("", "pipeline_search_index", false, 0, 0, null, null, true, "{\"query\":{\"bool\":{}}}", null, false, null ); -String data = IOUtils.toString(response.body().asInputStream(), Charsets.UTF_8); +try { + var table = client.tables().getByName("mysql-prod.employees.public.missing"); +} catch (OpenMetadataException e) { + if (e.getStatusCode() == 404) { + System.out.println("Table not found"); + } else { + System.out.println("Request failed: " + e.getMessage()); + } +} ``` ## More examples diff --git a/v1.13.x/sdk/java/info.mdx b/v1.13.x/sdk/java/info.mdx index ba454d280..668b4715f 100644 --- a/v1.13.x/sdk/java/info.mdx +++ b/v1.13.x/sdk/java/info.mdx @@ -6,7 +6,7 @@ sidebarTitle: Java SDK Info # Java SDK -The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers comprehensive support for entity management, authentication, and integration with enterprise Java applications. +The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers support for entity management, search, lineage, and authentication with a JWT token. ## Installation @@ -35,85 +35,87 @@ implementation 'org.open-metadata:openmetadata-sdk:1.13.6' ### Basic Connection ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; -import org.openmetadata.client.auth.BasicAuthProvider; - -// Create client with basic authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new BasicAuthProvider("admin", "admin")) +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.network.HttpMethod; + +// Create a client with a JWT token +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") .build(); -// Health check -if (client.healthCheck()) { - System.out.println("Successfully connected to OpenMetadata!"); -} -``` - -### JWT Authentication - -```java -import org.openmetadata.client.auth.JWTAuthProvider; +OpenMetadataClient client = new OpenMetadataClient(config); -// Create client with JWT authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new JWTAuthProvider("your-jwt-token")) - .build(); +// Check the connection by reading the server version +String version = client.getHttpClient() + .executeForString(HttpMethod.GET, "/v1/system/version", null); +System.out.println("Connected to OpenMetadata: " + version); ``` +For more information about getting a token, see [Authentication](/v1.13.x/api-reference/authentication). + ## Core Functionality ### Working with Entities +Every entity type has a service on the client, such as `client.databaseServices()`, `client.tables()`, and `client.users()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. + #### Database Services ```java -import org.openmetadata.schema.entity.services.DatabaseService; import org.openmetadata.schema.api.services.CreateDatabaseService; +import org.openmetadata.schema.api.services.DatabaseConnection; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.services.connections.database.MysqlConnection; +import org.openmetadata.sdk.models.ListParams; -// List all database services -List services = client.listDatabaseServices(); -System.out.println("Found " + services.size() + " database services"); +// List database services +var services = client.databaseServices().list(new ListParams().setLimit(50)); +System.out.println("Found " + services.getData().size() + " database services"); // Get specific service by name -DatabaseService service = client.getDatabaseServiceByName("mysql-prod"); +DatabaseService service = client.databaseServices().getByName("mysql-prod"); // Create new database service CreateDatabaseService createRequest = new CreateDatabaseService() .withName("new-mysql-service") - .withServiceType(DatabaseServiceType.MYSQL) - .withDescription("Production MySQL database"); - -DatabaseService newService = client.createDatabaseService(createRequest); + .withServiceType(CreateDatabaseService.DatabaseServiceType.Mysql) + .withDescription("Production MySQL database") + .withConnection(new DatabaseConnection().withConfig( + new MysqlConnection() + .withHostPort("localhost:3306") + .withUsername("openmetadata_user"))); + +DatabaseService newService = client.databaseServices().create(createRequest); ``` #### Tables ```java -import org.openmetadata.schema.entity.data.Table; +import java.util.List; import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; +import org.openmetadata.sdk.models.ListParams; // Get table by fully qualified name -Table table = client.getTableByName("mysql-prod.employees.employees"); -if (table != null) { - System.out.println("Table: " + table.getName()); - System.out.println("Columns: " + table.getColumns().size()); -} +Table table = client.tables().getByName("mysql-prod.employees.public.employees", "columns"); +System.out.println("Table: " + table.getName()); +System.out.println("Columns: " + table.getColumns().size()); -// List tables with pagination -EntityList
tables = client.listTables( - 10, // limit - null, // after cursor - "mysql-prod" // service filter -); +// List tables in a schema with pagination +var tables = client.tables().list( + new ListParams() + .setLimit(10) + .addFilter("databaseSchema", "mysql-prod.employees.public")); // Create table CreateTable createTable = new CreateTable() .withName("new_table") - .withDatabaseSchema("mysql-prod.employees") - .withColumns(Arrays.asList( + .withDatabaseSchema("mysql-prod.employees.public") + .withColumns(List.of( new Column() .withName("id") .withDataType(ColumnDataType.BIGINT) @@ -125,7 +127,7 @@ CreateTable createTable = new CreateTable() .withDescription("Employee name") )); -Table newTable = client.createTable(createTable); +Table newTable = client.tables().create(createTable); ``` ### Entity Operations @@ -133,111 +135,83 @@ Table newTable = client.createTable(createTable); #### CRUD Operations ```java -// Create or Update -DatabaseService service = client.createOrUpdateDatabaseService(createRequest); +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.network.HttpMethod; + +// Create or update a table +Table table = client.tables().createOrUpdate(createTable); + +// Create or update a database service +DatabaseService service = client.getHttpClient().execute( + HttpMethod.PUT, "/v1/services/databaseServices", createRequest, DatabaseService.class); // Get by ID -UUID serviceId = UUID.fromString("service-uuid-here"); -DatabaseService service = client.getDatabaseServiceById(serviceId); +UUID serviceId = service.getId(); +DatabaseService sameService = client.databaseServices().get(serviceId); // Delete -client.deleteDatabaseService(serviceId, false); // soft delete -client.deleteDatabaseService(serviceId, true); // hard delete +client.databaseServices().delete(serviceId.toString()); // soft delete +client.databaseServices().delete(serviceId.toString(), Map.of("hardDelete", "true")); // hard delete ``` #### Search and Filtering ```java -// Search tables -SearchRequest searchRequest = new SearchRequest() - .withQuery("customer") - .withEntityTypes(Arrays.asList("table")) - .withSize(50); - -SearchResponse results = client.search(searchRequest); -for (SearchHit hit : results.getHits()) { - System.out.println("Found: " + hit.getDisplayName()); -} +import org.openmetadata.sdk.models.ListParams; + +// Search tables. The response is the raw JSON from the server. +String results = client.search() + .query("customer") + .index("table_search_index") + .size(50) + .execute(); +System.out.println(results); // Advanced filtering -EntityList
customerTables = client.listTables( - 100, - null, - Map.of( - "service", "mysql-prod", - "database", "ecommerce" - ) -); +var customerTables = client.tables().list( + new ListParams() + .setLimit(100) + .addFilter("database", "mysql-prod.ecommerce")); ``` ## Advanced Features -### Authentication Providers - -#### Custom Authentication - -```java -import org.openmetadata.client.auth.AuthProvider; - -public class CustomAuthProvider implements AuthProvider { - private String customToken; - - public CustomAuthProvider(String token) { - this.customToken = token; - } - - @Override - public String getAuthToken() { - return "Bearer " + customToken; - } - - @Override - public void refresh() { - // Implement token refresh logic - } -} - -// Use custom auth provider -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(new CustomAuthProvider("custom-token")) - .build(); -``` +### Authentication -#### OAuth 2.0 Integration +The Java SDK authenticates with a JWT access token. When your token changes, create a new client with the new token: ```java -import org.openmetadata.client.auth.OAuth2AuthProvider; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -OAuth2AuthProvider authProvider = OAuth2AuthProvider.builder() - .clientId("your-client-id") - .clientSecret("your-client-secret") - .tokenUrl("https://auth.provider.com/oauth/token") - .scopes(Arrays.asList("read", "write")) - .build(); +String newToken = "your-new-jwt-token"; -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(authProvider) - .build(); +OpenMetadataClient client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl("https://your-instance.com/api") + .accessToken(newToken) + .build()); ``` ### Error Handling ```java -import org.openmetadata.client.exception.OpenMetadataException; +import org.openmetadata.sdk.exceptions.OpenMetadataException; try { - Table table = client.getTableByName("non-existent-table"); + var table = client.tables().getByName("non-existent-table"); } catch (OpenMetadataException e) { - switch (e.getErrorCode()) { - case NOT_FOUND: + switch (e.getStatusCode()) { + case 404: System.out.println("Table not found"); break; - case UNAUTHORIZED: + case 401: System.out.println("Authentication failed"); break; - case FORBIDDEN: + case 403: System.out.println("Access denied"); break; default: @@ -248,15 +222,22 @@ try { ### Async Operations +The service methods are blocking. To run them in parallel, wrap them in a `CompletableFuture`: + ```java +import java.util.List; import java.util.concurrent.CompletableFuture; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.models.ListParams; -// Async client operations CompletableFuture> servicesFuture = - client.listDatabaseServicesAsync(); + CompletableFuture.supplyAsync( + () -> client.databaseServices().list(new ListParams().setLimit(50)).getData()); CompletableFuture
tableFuture = - client.getTableByNameAsync("mysql-prod.employees.employees"); + CompletableFuture.supplyAsync( + () -> client.tables().getByName("mysql-prod.employees.public.employees", "columns")); // Combine async operations CompletableFuture combinedFuture = CompletableFuture.allOf( @@ -280,39 +261,19 @@ CompletableFuture combinedFuture = CompletableFuture.allOf( ### Client Configuration ```java -import org.openmetadata.client.config.ClientConfig; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -ClientConfig config = ClientConfig.builder() - .connectionTimeout(30000) // 30 seconds +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .connectTimeout(30000) // 30 seconds .readTimeout(60000) // 60 seconds - .retryCount(3) // Retry failed requests 3 times - .enableLogging(true) // Enable request/response logging - .enableMetrics(true) // Enable client metrics - .userAgent("MyApp/1.0") // Custom user agent + .writeTimeout(60000) // 60 seconds + .header("User-Agent", "MyApp/1.0") // Custom header on every request .build(); -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(authProvider) - .config(config) - .build(); -``` - -### Connection Pooling - -```java -import org.openmetadata.client.config.ConnectionPoolConfig; - -ConnectionPoolConfig poolConfig = ConnectionPoolConfig.builder() - .maxTotal(100) // Maximum total connections - .maxPerRoute(20) // Maximum connections per route - .connectionTTL(300000) // Connection TTL in milliseconds - .validateAfterInactivity(10000) // Validate connections after 10s - .build(); - -ClientConfig config = ClientConfig.builder() - .connectionPoolConfig(poolConfig) - .build(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ## Common Use Cases @@ -320,15 +281,26 @@ ClientConfig config = ClientConfig.builder() ### Metadata Discovery ```java -// Discover all tables in a service -String serviceName = "mysql-prod"; +import java.util.ArrayList; +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + +// Discover all tables in a schema +String schemaName = "mysql-prod.employees.public"; List
allTables = new ArrayList<>(); String after = null; do { - EntityList
batch = client.listTables(100, after, serviceName); + var params = new ListParams() + .setLimit(100) + .addFilter("databaseSchema", schemaName); + if (after != null) { + params.setAfter(after); + } + var batch = client.tables().list(params); allTables.addAll(batch.getData()); - after = batch.getAfter(); + after = batch.getPaging().getAfter(); } while (after != null); System.out.println("Discovered " + allTables.size() + " tables"); @@ -337,17 +309,19 @@ System.out.println("Discovered " + allTables.size() + " tables"); ### Bulk Operations ```java +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + // Bulk update table descriptions -List
tables = client.listAllTablesInService("mysql-prod"); +List
tables = client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", "mysql-prod.employees.public")) + .getData(); for (Table table : tables) { if (table.getDescription() == null || table.getDescription().isEmpty()) { - CreateTable updateRequest = new CreateTable() - .withName(table.getName()) - .withDatabaseSchema(table.getDatabaseSchema().getFullyQualifiedName()) - .withDescription("Auto-generated description for " + table.getName()); - - client.createOrUpdateTable(updateRequest); + table.setDescription("Auto-generated description for " + table.getName()); + client.tables().update(table.getId().toString(), table); } } ``` @@ -355,87 +329,61 @@ for (Table table : tables) { ### Lineage Operations ```java -import org.openmetadata.schema.type.EntityLineage; - -// Get table lineage -EntityLineage lineage = client.getTableLineage( - "mysql-prod.employees.employees", - 1, // upstream depth - 1 // downstream depth +// Get table lineage as JSON (1 hop upstream, 1 hop downstream) +String lineage = client.lineage().getLineageByName( + "table", + "mysql-prod.employees.public.employees", + "1", // upstream depth + "1" // downstream depth ); -System.out.println("Upstream entities: " + lineage.getUpstreamEdges().size()); -System.out.println("Downstream entities: " + lineage.getDownstreamEdges().size()); +System.out.println(lineage); ``` -## Spring Boot Integration +For more information about the fluent API for lineage, see [Java SDK for Lineage](/v1.13.x/api-reference/sdk/java/lineage). -### Configuration Class +## Use the Client in Your Application -```java -@Configuration -@EnableConfigurationProperties(OpenMetadataProperties.class) -public class OpenMetadataConfig { - - @Bean - public OpenMetadataClient openMetadataClient(OpenMetadataProperties properties) { - return OpenMetadataClient.builder() - .baseUrl(properties.getBaseUrl()) - .authProvider(new JWTAuthProvider(properties.getJwtToken())) - .build(); - } -} - -@ConfigurationProperties(prefix = "openmetadata") -@Data -public class OpenMetadataProperties { - private String baseUrl; - private String jwtToken; -} -``` - -### Service Layer +Create one `OpenMetadataClient` and share it across your application. If you use a framework such as Spring Boot, register the client as a singleton bean. ```java -@Service -public class MetadataService { +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.models.ListParams; - private final OpenMetadataClient client; +class MetadataService { - public MetadataService(OpenMetadataClient client) { - this.client = client; - } + private final OpenMetadataClient client; - public List
getTablesForService(String serviceName) { - return client.listAllTablesInService(serviceName); + public MetadataService(String baseUrl, String jwtToken) { + this.client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl(baseUrl) + .accessToken(jwtToken) + .build()); } - public Table createTable(CreateTableRequest request) { - CreateTable createTable = new CreateTable() - .withName(request.getName()) - .withDatabaseSchema(request.getSchemaFqn()) - .withColumns(request.getColumns()); - - return client.createTable(createTable); + public java.util.List getTablesForSchema(String schemaFqn) { + return client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", schemaFqn)) + .getData(); } } ``` ## Best Practices -1. **Resource Management**: Always close clients when done -2. **Connection Pooling**: Use connection pooling for high-throughput applications -3. **Error Handling**: Implement proper retry logic and error handling -4. **Authentication**: Use secure authentication methods in production -5. **Async Operations**: Use async methods for better performance in concurrent scenarios -6. **Pagination**: Always handle pagination for large datasets -7. **Caching**: Implement caching for frequently accessed entities +- **Reuse the client**: Create one client and share it instead of creating a new one per request. +- **Handle errors**: Catch `OpenMetadataException` and check the status code. +- **Protect authentication**: Keep your JWT token in a secret store, not in source code. +- **Use async operations**: Wrap calls in `CompletableFuture` for better performance in concurrent scenarios. +- **Handle pagination**: Always handle pagination for large datasets. +- **Cache entities**: Implement caching for frequently accessed entities. ## Performance Tips -- Use batch operations when possible -- Implement connection pooling for high-concurrency applications -- Cache frequently accessed metadata -- Use async operations for better throughput -- Specify only required fields when fetching entities -- Implement proper retry strategies with exponential backoff \ No newline at end of file +- Create one client and reuse it. +- Cache frequently accessed metadata. +- Run independent calls in parallel with `CompletableFuture`. +- Specify only required fields when fetching entities. +- Use filters to narrow lists before you read them. diff --git a/v1.13.x/sdk/overview.mdx b/v1.13.x/sdk/overview.mdx index 04dffe6ea..c0b2af470 100644 --- a/v1.13.x/sdk/overview.mdx +++ b/v1.13.x/sdk/overview.mdx @@ -2,6 +2,8 @@ title: OpenMetadata SDKs description: 'Official client libraries for Python, Java, and Go to integrate with OpenMetadata APIs. Type-safe, full-featured SDKs for metadata management and automation.' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # OpenMetadata SDKs @@ -25,7 +27,7 @@ Official client libraries provide type-safe, full-featured access to OpenMetadat - Full-featured Python client + Original Client and SDK 2.0 (`metadata.sdk`) Enterprise Java integration @@ -44,15 +46,24 @@ Perfect for: - ML pipeline automation - Data quality automation +SDK 2.0 (`metadata.sdk`, OpenMetadata 1.10.0 and later): + + + +Original client: + ```python from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( OpenMetadataConnection, ) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) from metadata.ingestion.ometa.ometa_api import OpenMetadata server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -69,13 +80,15 @@ Perfect for: - Legacy system integration ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; + +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .build(); -OpenMetadataClient client = new OpenMetadataClient( - "http://localhost:8585/api", - "your-jwt-token" -); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ### Go SDK @@ -86,11 +99,11 @@ Perfect for: - High-performance services ```go -import "github.com/open-metadata/openmetadata-go-client" +import "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" -client := openmetadata.NewClient( - "http://localhost:8585/api", - "your-jwt-token", +client := ometa.NewClient( + "http://localhost:8585", + ometa.WithToken("your-jwt-token"), ) ``` diff --git a/v1.13.x/sdk/python.mdx b/v1.13.x/sdk/python.mdx index 2b2c2dd2b..ab595c978 100644 --- a/v1.13.x/sdk/python.mdx +++ b/v1.13.x/sdk/python.mdx @@ -3,6 +3,8 @@ title: Python SDK | OpenMetadata Python SDK Documentation description: Master OpenMetadata'sPython SDK with comprehensive documentation, code examples, and API guides. Build powerful data discovery and governance solutions. sidebarTitle: Overview --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -17,7 +19,7 @@ We are now going to present a high-level Python API as a type-safe and gentle wr - Make sure to use the same `openmetadata-ingestion` version as your server version. For example, if you have the OpenMetadata server at version 1.13.6, you will need to install: -```python +```bash pip install "openmetadata-ingestion~=1.13.6.0" ``` @@ -30,7 +32,15 @@ In the [OpenMetadata Design](/v1.13.x/developers/architecture), we have been dis This means that whenever we need to interact with the metadata system or develop a new connector or logic, we have to make sure that we pass the proper inputs and handle the types of outputs. -## Introducing the Python API + + +## SDK 2.0 Quick Start + +Connect with `configure()`, then create, update, and delete a table: + + + +## Introducing the Python API (Original Client) Let's suppose that we have our local OpenMetadata server running at `http:localhost:8585`. We can play with it with simple `cURL` or `httpie` commands, and if we just want to take a look at the Entity instances we have lying around, that might probably be enough. However, let's imagine that we want to create or update an ML Model Entity with a `PUT`. To do so, we need to make sure that we are providing a proper JSON, covering all the attributes and types required by the Entity definition. @@ -202,7 +212,7 @@ server_config = OpenMetadataConnection( securityConfig=OpenMetadataJWTClientConfig( jwtToken="", ), - verifySSL="validate" # ignore, validate or no-ssl, + verifySSL="validate", # ignore, validate or no-ssl sslConfig=ValidateSslClientConfig(caCertificate="/path/to/rootCert"), ) @@ -316,8 +326,8 @@ class CreateDatabaseRequest(BaseModel): None, description='Description of the database instance. What it has and how to use it.', ) - owner: Optional[entityReference.EntityReference] = Field( - None, description='Owner of this database' + owners: Optional[entityReferenceList.EntityReferenceList] = Field( + None, description='Owners of this database' ) service: basic.FullyQualifiedEntityName = Field( ..., @@ -331,7 +341,7 @@ class CreateDatabaseRequest(BaseModel): Note how the only non-optional fields are `name` and `service`. The type of `service`, however, is `FullyQualifiedEntityName`. This is expected, as there we need to pass the information of an existing Entity. In our case, the `fullyQualifiedName` of the `DatabaseService` we just created. -In the case of the `owner` field, repeating the exercise and reviewing the required fields to instantiate an `EntityReference` we notice how we need to pass an `id: uuid.UUID` and `type: str`. There we need to specify the `id` and `type` of an `User`. +The `owners` field takes a list of `EntityReference`. To instantiate an `EntityReference`, pass an `id: uuid.UUID` and `type: str`. Specify the `id` and `type` of a `User`. **Querying by name** @@ -400,8 +410,8 @@ Let's now update the `Table` by adding an owner. This will require us to create First, make sure that no owner has been set during the creation: ```python -print(table_entity.owner) -# None +print(table_entity.owners) +# root=[] ``` Now, create a `User`: @@ -414,19 +424,19 @@ user = metadata.create_or_update( ) ``` -Update our instance of `create_table` to add the `owner` field (we need to use the `Create` class as we'll run a `PUT`), and update the Entity: +Update your `create_table` instance to add the `owners` field. Use the `Create` class, because this runs a `PUT`. Then update the Entity: ```python from metadata.generated.schema.type.entityReference import EntityReference -create_table.owner = EntityReference(id=user.id, type="user") +create_table.owners = [EntityReference(id=user.id, type="user")] updated_table_entity = metadata.create_or_update(create_table) -print(updated_table_entity.owner) -# EntityReference(id=Uuid(__root__=UUID('48793f0c-5308-45c1-9bf4-06a82c8d7bf9')), type='user', name='random-user', description=None, displayName=None, href=Href(__root__=AnyUrl('http://localhost:8585/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9', scheme='http', host='localhost', host_type='int_domain', port='8585', path='/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9'))) +print(updated_table_entity.owners.root[0].name) +# random-user ``` -If we did not save the `updated_table_entity` variable, we should need to query it to review the `owner` field. We can run the `get_by_name` using the proper FQN definition for `Table`s: +If you didn't save the `updated_table_entity` variable, query it to review the `owners` field. Run `get_by_name` with the FQN of the table: ```python my_table = metadata.get_by_name(entity=Table, fqn="test-service-table.test-db.test-schema.test") diff --git a/v1.13.x/sdk/python/api-reference.mdx b/v1.13.x/sdk/python/api-reference.mdx index 0d71ee1d0..97db722c3 100644 --- a/v1.13.x/sdk/python/api-reference.mdx +++ b/v1.13.x/sdk/python/api-reference.mdx @@ -33,6 +33,7 @@ All entity types follow the same pattern: from metadata.sdk import Tables, Databases, DatabaseSchemas, DatabaseServices from metadata.sdk import Dashboards, Pipelines, MLModels, Tags, Classifications from metadata.sdk import Glossaries, GlossaryTerms, Users, Teams +from metadata.generated.schema.api.data.createTable import CreateTableRequest # Create entity = Tables.create(CreateTableRequest(...)) @@ -41,13 +42,18 @@ entity = Tables.create(CreateTableRequest(...)) entity = Tables.retrieve("uuid") entity = Tables.retrieve_by_name("service.db.schema.table", fields=["owners", "tags"]) -# List with auto-pagination -for table in Tables.list().auto_paging_iterable(): - print(table.name) +# List one page +page = Tables.list(limit=50) +for table in page.entities: + print(table.name.root) + +# List everything (follows the paging cursor for you) +for table in Tables.list_all(): + print(table.name.root) # Update entity.description = "Updated" -Tables.update(str(entity.id), entity) +Tables.update(entity) # Delete Tables.delete("uuid") @@ -68,7 +74,7 @@ Lineage.add_lineage( ) # Get lineage -lineage = Lineage.get_lineage("service.db.schema.table", upstream_depth=2, downstream_depth=2) +lineage = Lineage.get_lineage("service.db.schema.table", entity_type="table", upstream_depth=2, downstream_depth=2) ``` ### Error Handling @@ -78,9 +84,9 @@ from metadata.ingestion.ometa.client import APIError try: table = Tables.retrieve("table-id") -except APIError as e: - if e.status_code == 404: + if table is None: print("Not found") - elif e.status_code == 401: +except APIError as e: + if e.status_code == 401: print("Authentication failed") ``` diff --git a/v1.13.x/sdk/python/overview.mdx b/v1.13.x/sdk/python/overview.mdx index c193ace70..f65fdec21 100644 --- a/v1.13.x/sdk/python/overview.mdx +++ b/v1.13.x/sdk/python/overview.mdx @@ -2,6 +2,8 @@ title: Python SDK Overview description: 'Full-featured Python client library for OpenMetadata integration' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -15,7 +17,17 @@ Install the OpenMetadata Python SDK using pip: pip install openmetadata-ingestion ``` -## Quick Start + + +## Quick Start: SDK 2.0 + +Connect with `configure()`, then create, update, and delete a table: + + + +## Quick Start: Original Client + +Connect with `OpenMetadataConnection`, then read and update entities: ### Basic Connection @@ -31,7 +43,7 @@ from metadata.generated.schema.security.client.openMetadataJWTClientConfig impor # Configure connection server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -62,7 +74,7 @@ table = metadata.get_by_name( ) if table: - print(f"Table: {table.name}") + print(f"Table: {table.name.root}") print(f"Columns: {len(table.columns) if table.columns else 0}") ``` @@ -106,7 +118,7 @@ table = metadata.get_by_name( # List entities with pagination tables = metadata.list_entities( entity=Table, - fields=["owner", "tags"], + fields=["owners", "tags"], limit=50 ) ``` @@ -117,12 +129,12 @@ tables = metadata.list_entities( # Generator for large datasets all_tables = metadata.list_all_entities( entity=Table, - fields=["owner", "columns"], - params={"service": "your-service-name"} + fields=["owners", "columns"], + params={"databaseSchema": "your-service.your-database.your-schema"} ) for table in all_tables: - print(f"Processing table: {table.name}") + print(f"Processing table: {table.name.root}") ``` ### Entity References @@ -136,26 +148,26 @@ table_ref = metadata.get_entity_reference( # Use in other entity creation if table_ref: - print(f"Table reference: {table_ref.id}") + print(f"Table reference: {table_ref.id.root}") ``` ## Advanced Features -### Custom Configuration +### Validating a Custom Certificate Authority (CA) Certificate + +To trust a private CA, pass the path to its certificate in `sslConfig`: ```python -# Using custom authentication -from metadata.generated.schema.security.client.basicAuthenticationProvider import ( - BasicAuthenticationProvider, -) +from metadata.generated.schema.security.ssl.validateSSLClientConfig import ValidateSslClientConfig server_config = OpenMetadataConnection( hostPort="https://your-openmetadata-instance.com/api", - authProvider="basic", - securityConfig=BasicAuthenticationProvider( - username="your-username", - password="your-password" + authProvider="openmetadata", + securityConfig=OpenMetadataJWTClientConfig( + jwtToken="your-jwt-token" ), + verifySSL="validate", + sslConfig=ValidateSslClientConfig(caCertificate="/path/to/rootCert"), ) metadata = OpenMetadata(server_config) @@ -164,18 +176,10 @@ metadata = OpenMetadata(server_config) ### Error Handling ```python -from metadata.ingestion.ometa.ometa_api import ( - OpenMetadata, - InvalidEntityException, - EmptyPayloadException -) - -try: - table = metadata.get_by_name(entity=Table, fqn="non-existent-table") -except InvalidEntityException as e: - print(f"Invalid entity: {e}") -except EmptyPayloadException as e: - print(f"No data received: {e}") +# get_by_name returns None when the entity does not exist +table = metadata.get_by_name(entity=Table, fqn="non-existent-table") +if table is None: + print("Table not found") ``` ### Working with Versions @@ -200,11 +204,11 @@ all_tables = metadata.list_all_entities(entity=Table) matching_tables = [ table for table in all_tables - if "customer" in table.name.lower() + if "customer" in table.name.root.lower() ] for table in matching_tables: - print(f"Found customer table: {table.fullyQualifiedName}") + print(f"Found customer table: {table.fullyQualifiedName.root}") ``` ### Metadata Automation @@ -213,30 +217,28 @@ for table in matching_tables: # Bulk update table descriptions tables_to_update = metadata.list_all_entities( entity=Table, - params={"service": "production-db"} + params={"databaseSchema": "production-service.production-db.public"} ) for table in tables_to_update: if not table.description: # Update with a default description - table.description = f"Production table: {table.name}" + table.description = f"Production table: {table.name.root}" metadata.create_or_update(data=table) ``` ### Lineage Management ```python -from metadata.generated.schema.type.entityLineage import EntityLineage - -# Get table lineage +# Get table lineage (returns a dict) lineage = metadata.get_lineage_by_name( entity=Table, fqn="service.database.schema.table" ) if lineage: - print(f"Upstream entities: {len(lineage.upstreamEdges)}") - print(f"Downstream entities: {len(lineage.downstreamEdges)}") + print(f"Upstream edges: {len(lineage['upstreamEdges'])}") + print(f"Downstream edges: {len(lineage['downstreamEdges'])}") ``` ## API Reference diff --git a/v2.0.x/api-reference.mdx b/v2.0.x/api-reference.mdx index daacf3d1f..612ec6db4 100644 --- a/v2.0.x/api-reference.mdx +++ b/v2.0.x/api-reference.mdx @@ -86,10 +86,14 @@ metadata = OpenMetadata(server_config) # List tables tables = metadata.list_all_entities(entity=Table) for table in tables: - print(f"{table.fullyQualifiedName}: {table.description}") + print(f"{table.fullyQualifiedName.root}: {getattr(table.description, 'root', table.description)}") ``` ```java Java +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.models.ListParams; + // Configure connection OpenMetadataConfig config = OpenMetadataConfig.builder() .serverUrl("https://your-company.open-metadata.org/api") @@ -99,9 +103,8 @@ OpenMetadataConfig config = OpenMetadataConfig.builder() OpenMetadataClient client = new OpenMetadataClient(config); // List tables -TablesApi tablesApi = client.buildClient(TablesApi.class); -TableList tables = tablesApi.listTables(null, 10, null, null, null); -for (Table table : tables.getData()) { +var tables = client.tables().list(new ListParams().setLimit(10)); +for (var table : tables.getData()) { System.out.println(table.getFullyQualifiedName()); } ``` diff --git a/v2.0.x/api-reference/ai-assets/llm.mdx b/v2.0.x/api-reference/ai-assets/llm.mdx index 97237ee5d..330d78844 100644 --- a/v2.0.x/api-reference/ai-assets/llm.mdx +++ b/v2.0.x/api-reference/ai-assets/llm.mdx @@ -71,6 +71,8 @@ The Java example assumes a configured `OpenMetadataClient` named `client`. import org.openmetadata.schema.api.ai.CreateLLMModel; import org.openmetadata.schema.api.services.CreateLLMService; +// client is an initialized OpenMetadataClient. + var service = client.llmServices().create( new CreateLLMService() .withName("openai_production") diff --git a/v2.0.x/api-reference/ai-assets/mcp.mdx b/v2.0.x/api-reference/ai-assets/mcp.mdx index 6fdabaa62..257b03294 100644 --- a/v2.0.x/api-reference/ai-assets/mcp.mdx +++ b/v2.0.x/api-reference/ai-assets/mcp.mdx @@ -98,6 +98,8 @@ import org.openmetadata.schema.api.ai.CreateMcpServer; import org.openmetadata.schema.entity.ai.McpServerType; import org.openmetadata.schema.entity.ai.McpTransportType; +// client is an initialized OpenMetadataClient. + var server = client.mcpServers().create( new CreateMcpServer() .withName("warehouse_tools") diff --git a/v2.0.x/api-reference/ai-assets/prompt-templates.mdx b/v2.0.x/api-reference/ai-assets/prompt-templates.mdx index 2f61e4984..5f323cabb 100644 --- a/v2.0.x/api-reference/ai-assets/prompt-templates.mdx +++ b/v2.0.x/api-reference/ai-assets/prompt-templates.mdx @@ -40,6 +40,8 @@ The Java example assumes a configured `OpenMetadataClient` named `client`. ```java Java SDK import org.openmetadata.schema.api.ai.CreatePromptTemplate; +// client is an initialized OpenMetadataClient. + var template = client.promptTemplates().create( new CreatePromptTemplate() .withName("summarize_support_cases") diff --git a/v2.0.x/api-reference/authentication.mdx b/v2.0.x/api-reference/authentication.mdx index 3a8290f72..045c85946 100644 --- a/v2.0.x/api-reference/authentication.mdx +++ b/v2.0.x/api-reference/authentication.mdx @@ -81,21 +81,17 @@ tables = metadata.list_all_entities(entity=Table) ``` ```java Token Example -import org.openmetadata.client.gateway.OpenMetadata; -import org.openmetadata.schema.services.connections.metadata.OpenMetadataConnection; -import org.openmetadata.schema.security.client.OpenMetadataJWTClientConfig; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; // Configure with JWT token -OpenMetadataConnection config = new OpenMetadataConnection(); -config.setHostPort("https://your-company.open-metadata.org/api"); -config.setAuthProvider(AuthProvider.OPENMETADATA); - -OpenMetadataJWTClientConfig jwtConfig = new OpenMetadataJWTClientConfig(); -jwtConfig.setJwtToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."); -config.setSecurityConfig(jwtConfig); +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("https://your-company.open-metadata.org/api") + .accessToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...") + .build(); // Create authenticated client -OpenMetadata client = new OpenMetadata(config); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ```bash Token Example diff --git a/v2.0.x/api-reference/data-assets/api-collections/create.mdx b/v2.0.x/api-reference/data-assets/api-collections/create.mdx index f0abc3fef..7a97e534c 100644 --- a/v2.0.x/api-reference/data-assets/api-collections/create.mdx +++ b/v2.0.x/api-reference/data-assets/api-collections/create.mdx @@ -16,11 +16,11 @@ Create a new API collection within an API service. - Fully qualified name of the parent APIService (e.g., `sample_api_service`). + Fully qualified name of the parent APIService, for example `sample_api_service`. - Base URL for the API collection (e.g., `https://petstore3.swagger.io/#/pet`). + Base URL for the API collection, for example `https://petstore3.swagger.io/#/pet`. @@ -40,7 +40,7 @@ Create a new API collection within an API service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -49,8 +49,8 @@ Create a new API collection within an API service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -62,11 +62,11 @@ Create a new API collection within an API service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -94,19 +94,23 @@ request = CreateAPICollectionRequest( ) api_collection = APICollections.create(request) -print(f"Created: {api_collection.fullyQualifiedName}") +print(f"Created: {api_collection.fullyQualifiedName.root}") ``` ```java POST /v1/apiCollections -import static org.openmetadata.sdk.fluent.APICollections.*; - -// Create using builder pattern -var apiCollection = APICollections.builder() - .name("pet") - .service("sample_api_service") - .endpointURL("https://petstore3.swagger.io/#/pet") - .description("Pet-related API endpoints") - .create(); +import java.net.URI; +import org.openmetadata.schema.api.data.CreateAPICollection; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. + +CreateAPICollection request = new CreateAPICollection() + .withName("pet") + .withService("sample_api_service") + .withEndpointURL(URI.create("https://petstore3.swagger.io/#/pet")) + .withDescription("Pet-related API endpoints"); + +APICollection apiCollection = client.apiCollections().create(request); ``` ```bash POST /v1/apiCollections @@ -204,7 +208,7 @@ Returns the created API collection object with all specified properties and syst - Type of API service (e.g., Rest). + Type of API service, for example Rest. @@ -216,7 +220,7 @@ Returns the created API collection object with all specified properties and syst - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -238,11 +242,11 @@ Returns the created API collection object with all specified properties and syst - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/api-collections/delete.mdx b/v2.0.x/api-reference/data-assets/api-collections/delete.mdx index b70156430..66238adf7 100644 --- a/v2.0.x/api-reference/data-assets/api-collections/delete.mdx +++ b/v2.0.x/api-reference/data-assets/api-collections/delete.mdx @@ -28,7 +28,7 @@ Delete an API collection by ID or fully qualified name. Supports soft delete (de Use `DELETE /v1/apiCollections/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the API collection (e.g., `sample_api_service.pet`). + Fully qualified name of the API collection, for example `sample_api_service.pet`. @@ -66,36 +66,40 @@ APICollections.delete( hard_delete=True ) -# Delete by name -APICollections.delete_by_name("sample_api_service.pet") +# Delete by name (look up the ID first) +entity = APICollections.retrieve_by_name("sample_api_service.pet") +APICollections.delete(entity.id) # Delete by name with options -APICollections.delete_by_name( - "sample_api_service.pet", - hard_delete=True -) +entity = APICollections.retrieve_by_name("sample_api_service.pet") +APICollections.delete(entity.id, hard_delete=True) # Restore a soft-deleted API collection APICollections.restore("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") ``` ```java DELETE /v1/apiCollections/{id} -import static org.openmetadata.sdk.fluent.APICollections.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -APICollections.delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b").execute(); +client.apiCollections().delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); // Hard delete -APICollections.delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") - .hardDelete() - .execute(); +client.apiCollections().delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b", Map.of("hardDelete", "true")); // Delete by name -APICollections.deleteByName("sample_api_service.pet") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/apiCollections/name/sample_api_service.pet", + null, + Void.class +); // Restore -APICollections.restore("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +client.apiCollections().restore("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); ``` ```bash DELETE /v1/apiCollections/{id} diff --git a/v2.0.x/api-reference/data-assets/api-collections/list.mdx b/v2.0.x/api-reference/data-assets/api-collections/list.mdx index 3407abaaf..07f3cc8e1 100644 --- a/v2.0.x/api-reference/data-assets/api-collections/list.mdx +++ b/v2.0.x/api-reference/data-assets/api-collections/list.mdx @@ -47,48 +47,53 @@ configure( # List first page collections = APICollections.list(limit=50) -for ac in collections.data: - print(f"{ac.fullyQualifiedName}") +for ac in collections.entities: + print(f"{ac.fullyQualifiedName.root}") # List all with auto-pagination for ac in APICollections.list_all(): - print(f"{ac.fullyQualifiedName}") + print(f"{ac.fullyQualifiedName.root}") # Filter by service collections = APICollections.list( - service="sample_api_service", - fields=["owners", "tags", "domain"], + filters={"service": "sample_api_service"}, + fields=["owners", "tags", "domains"], limit=50 ) -for ac in collections.data: - print(f"{ac.fullyQualifiedName}") +for ac in collections.entities: + print(f"{ac.fullyQualifiedName.root}") if ac.owners: - print(f" Owners: {[o.name for o in ac.owners]}") + print(f" Owners: {[o.name for o in ac.owners.root]}") if ac.tags: - print(f" Tags: {[t.tagFQN for t in ac.tags]}") + print(f" Tags: {[t.tagFQN.root for t in ac.tags]}") ``` ```java GET /v1/apiCollections -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. // List first page -var result = APICollections.list() - .limit(50) - .execute(); +ListResponse firstPage = client.apiCollections().list( + new ListParams().setLimit(50) +); -for (var ac : result.getData()) { +for (APICollection ac : firstPage.getData()) { System.out.println(ac.getFullyQualifiedName()); } // Filter by service with fields -var result = APICollections.list() - .service("sample_api_service") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var ac : result.getData()) { +ListResponse filtered = client.apiCollections().list( + new ListParams() + .setService("sample_api_service") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (APICollection ac : filtered.getData()) { System.out.println(ac.getFullyQualifiedName()); } ``` @@ -180,7 +185,7 @@ Returns a paginated list of API collection objects. By default, only basic field - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v2.0.x/api-reference/data-assets/api-collections/retrieve.mdx b/v2.0.x/api-reference/data-assets/api-collections/retrieve.mdx index f0e976e4f..6315ccb3d 100644 --- a/v2.0.x/api-reference/data-assets/api-collections/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/api-collections/retrieve.mdx @@ -16,7 +16,7 @@ Get a single API collection by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single API collection by its unique ID or fully qualified name. Use `GET /v1/apiCollections/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the API collection (e.g., `sample_api_service.pet`). + Fully qualified name of the API collection, for example `sample_api_service.pet`. @@ -51,7 +51,7 @@ configure( # Get by ID ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") -print(f"{ac.fullyQualifiedName}: {ac.description}") +print(f"{ac.fullyQualifiedName.root}: {ac.name.root}") # Get by ID with fields ac = APICollections.retrieve( @@ -65,31 +65,33 @@ ac = APICollections.retrieve_by_name("sample_api_service.pet") # Get by name with fields ac = APICollections.retrieve_by_name( "sample_api_service.pet", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/apiCollections/{id} -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. // Get by ID -var ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +APICollection ac = client.apiCollections().get("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); // Get by ID with fields -var ac = APICollections.retrieve( +APICollection acWithFields = client.apiCollections().get( "0f7ee81c-8163-4097-8adb-45c3d6c7b14b", "owners,tags" ); // Get by fully qualified name -var ac = APICollections.retrieveByName( +APICollection acByName = client.apiCollections().getByName( "sample_api_service.pet" ); // Get by name with fields -var ac = APICollections.retrieveByName( +APICollection acByNameWithFields = client.apiCollections().getByName( "sample_api_service.pet", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -194,7 +196,7 @@ Returns an API collection object with all requested fields populated. - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v2.0.x/api-reference/data-assets/api-collections/update.mdx b/v2.0.x/api-reference/data-assets/api-collections/update.mdx index 38735efd1..65160f2a0 100644 --- a/v2.0.x/api-reference/data-assets/api-collections/update.mdx +++ b/v2.0.x/api-reference/data-assets/api-collections/update.mdx @@ -20,7 +20,7 @@ Update an API collection's properties using JSON Merge Patch. You can update by Use `PATCH /v1/apiCollections/name/{fqn}` to update by fully qualified name. - Fully qualified name of the API collection (e.g., `sample_api_service.pet`). + Fully qualified name of the API collection, for example `sample_api_service.pet`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -62,17 +62,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -94,16 +94,18 @@ ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") ac.description = "Updated: Pet-related API endpoints for the Petstore service" updated = APICollections.update(ac) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/apiCollections/{id} -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +APICollection ac = client.apiCollections().get("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); ac.setDescription("Updated: Pet-related API endpoints for the Petstore service"); -var updated = APICollections.update(ac); +APICollection updated = client.apiCollections().update("0f7ee81c-8163-4097-8adb-45c3d6c7b14b", ac); ``` ```bash PATCH /v1/apiCollections/{id} diff --git a/v2.0.x/api-reference/data-assets/api-collections/versions.mdx b/v2.0.x/api-reference/data-assets/api-collections/versions.mdx index 9fc8af7e1..7f880d3ce 100644 --- a/v2.0.x/api-reference/data-assets/api-collections/versions.mdx +++ b/v2.0.x/api-reference/data-assets/api-collections/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/apiCollections/{id}/versions/{version}` to retrieve a specific vers - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/apiCollections/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import APICollections @@ -40,28 +42,30 @@ configure( # List all versions versions = APICollections.get_versions("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version ac_v1 = APICollections.get_specific_version( "0f7ee81c-8163-4097-8adb-45c3d6c7b14b", "0.1" ) -print(f"Original description: {ac_v1.description}") +print(f"Original description: {ac_v1.description.root if ac_v1.description else None}") ``` ```java GET /v1/apiCollections/{id}/versions -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.schema.entity.data.APICollection; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = APICollections.getVersions("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +EntityHistory history = client.apiCollections().getVersionList("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = APICollections.getSpecificVersion( +APICollection v1 = client.apiCollections().getVersion( "0f7ee81c-8163-4097-8adb-45c3d6c7b14b", 0.1 ); diff --git a/v2.0.x/api-reference/data-assets/api-endpoints/create.mdx b/v2.0.x/api-reference/data-assets/api-endpoints/create.mdx index cc5043d76..372802543 100644 --- a/v2.0.x/api-reference/data-assets/api-endpoints/create.mdx +++ b/v2.0.x/api-reference/data-assets/api-endpoints/create.mdx @@ -16,11 +16,11 @@ Create a new API endpoint within an API collection. - Fully qualified name of the parent APICollection (e.g., `sample_api_service.pet`). + Fully qualified name of the parent APICollection, for example `sample_api_service.pet`. - URL for the API endpoint (e.g., `https://petstore3.swagger.io/#/pet/addPet`). + URL for the API endpoint, for example `https://petstore3.swagger.io/#/pet/addPet`. @@ -32,7 +32,7 @@ Create a new API endpoint within an API collection. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -44,7 +44,7 @@ Create a new API endpoint within an API collection. - Data type of the field (e.g., `INT`, `STRING`, `OBJECT`). + Data type of the field, for example `INT`, `STRING`, `OBJECT`. @@ -60,7 +60,7 @@ Create a new API endpoint within an API collection. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -100,7 +100,7 @@ Create a new API endpoint within an API collection. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -109,8 +109,8 @@ Create a new API endpoint within an API collection. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -122,11 +122,11 @@ Create a new API endpoint within an API collection. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -162,21 +162,26 @@ request = CreateAPIEndpointRequest( ) endpoint = APIEndpoints.create(request) -print(f"Created: {endpoint.fullyQualifiedName}") +print(f"Created: {endpoint.fullyQualifiedName.root}") ``` ```java POST /v1/apiEndpoints -import static org.openmetadata.sdk.fluent.APIEndpoints.*; - -// Create using builder pattern -var endpoint = APIEndpoints.builder() - .name("addPet") - .displayName("Add Pet") - .apiCollection("sample_api_service.pet") - .description("Add a new pet to the store") - .endpointURL("https://petstore3.swagger.io/#/pet/addPet") - .requestMethod("POST") - .create(); +import java.net.URI; +import org.openmetadata.schema.api.data.CreateAPIEndpoint; +import org.openmetadata.schema.entity.data.APIEndpoint; +import org.openmetadata.schema.type.APIRequestMethod; + +// client is an initialized OpenMetadataClient. + +CreateAPIEndpoint request = new CreateAPIEndpoint() + .withName("addPet") + .withDisplayName("Add Pet") + .withApiCollection("sample_api_service.pet") + .withDescription("Add a new pet to the store") + .withEndpointURL(URI.create("https://petstore3.swagger.io/#/pet/addPet")) + .withRequestMethod(APIRequestMethod.POST); + +APIEndpoint endpoint = client.apiEndpoints().create(request); ``` ```bash POST /v1/apiEndpoints @@ -276,7 +281,7 @@ Returns the created API endpoint object with all specified properties and system - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -290,7 +295,7 @@ Returns the created API endpoint object with all specified properties and system - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -318,7 +323,7 @@ Returns the created API endpoint object with all specified properties and system - Type of API service (e.g., Rest). + Type of API service, for example Rest. @@ -330,7 +335,7 @@ Returns the created API endpoint object with all specified properties and system - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -352,11 +357,11 @@ Returns the created API endpoint object with all specified properties and system - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/api-endpoints/delete.mdx b/v2.0.x/api-reference/data-assets/api-endpoints/delete.mdx index d5370aa3e..2dbcc6ec3 100644 --- a/v2.0.x/api-reference/data-assets/api-endpoints/delete.mdx +++ b/v2.0.x/api-reference/data-assets/api-endpoints/delete.mdx @@ -28,7 +28,7 @@ Delete an API endpoint by ID or fully qualified name. Supports soft delete (defa Use `DELETE /v1/apiEndpoints/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the API endpoint (e.g., `sample_api_service.pet.addPet`). + Fully qualified name of the API endpoint, for example `sample_api_service.pet.addPet`. @@ -66,36 +66,40 @@ APIEndpoints.delete( hard_delete=True ) -# Delete by name -APIEndpoints.delete_by_name("sample_api_service.pet.addPet") +# Delete by name (look up the ID first) +entity = APIEndpoints.retrieve_by_name("sample_api_service.pet.addPet") +APIEndpoints.delete(entity.id) # Delete by name with options -APIEndpoints.delete_by_name( - "sample_api_service.pet.addPet", - hard_delete=True -) +entity = APIEndpoints.retrieve_by_name("sample_api_service.pet.addPet") +APIEndpoints.delete(entity.id, hard_delete=True) # Restore a soft-deleted API endpoint APIEndpoints.restore("1f61427a-4a64-4070-9ac8-1d29302dac7c") ``` ```java DELETE /v1/apiEndpoints/{id} -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -APIEndpoints.delete("1f61427a-4a64-4070-9ac8-1d29302dac7c").execute(); +client.apiEndpoints().delete("1f61427a-4a64-4070-9ac8-1d29302dac7c"); // Hard delete -APIEndpoints.delete("1f61427a-4a64-4070-9ac8-1d29302dac7c") - .hardDelete() - .execute(); +client.apiEndpoints().delete("1f61427a-4a64-4070-9ac8-1d29302dac7c", Map.of("hardDelete", "true")); // Delete by name -APIEndpoints.deleteByName("sample_api_service.pet.addPet") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/apiEndpoints/name/sample_api_service.pet.addPet", + null, + Void.class +); // Restore -APIEndpoints.restore("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +client.apiEndpoints().restore("1f61427a-4a64-4070-9ac8-1d29302dac7c"); ``` ```bash DELETE /v1/apiEndpoints/{id} diff --git a/v2.0.x/api-reference/data-assets/api-endpoints/list.mdx b/v2.0.x/api-reference/data-assets/api-endpoints/list.mdx index 47ea4d849..86b88b86b 100644 --- a/v2.0.x/api-reference/data-assets/api-endpoints/list.mdx +++ b/v2.0.x/api-reference/data-assets/api-endpoints/list.mdx @@ -51,48 +51,53 @@ configure( # List first page endpoints = APIEndpoints.list(limit=50) -for ep in endpoints.data: - print(f"{ep.fullyQualifiedName}") +for ep in endpoints.entities: + print(f"{ep.fullyQualifiedName.root}") # List all with auto-pagination for ep in APIEndpoints.list_all(): - print(f"{ep.fullyQualifiedName}") + print(f"{ep.fullyQualifiedName.root}") # Filter by API collection endpoints = APIEndpoints.list( - apiCollection="sample_api_service.pet", - fields=["owners", "tags", "domain"], + filters={"apiCollection": "sample_api_service.pet"}, + fields=["owners", "tags", "domains"], limit=50 ) -for ep in endpoints.data: - print(f"{ep.fullyQualifiedName} [{ep.requestMethod}]") +for ep in endpoints.entities: + print(f"{ep.fullyQualifiedName.root} [{ep.requestMethod.value}]") if ep.owners: - print(f" Owners: {[o.name for o in ep.owners]}") + print(f" Owners: {[o.name for o in ep.owners.root]}") if ep.tags: - print(f" Tags: {[t.tagFQN for t in ep.tags]}") + print(f" Tags: {[t.tagFQN.root for t in ep.tags]}") ``` ```java GET /v1/apiEndpoints -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.APIEndpoint; + +// client is an initialized OpenMetadataClient. // List first page -var result = APIEndpoints.list() - .limit(50) - .execute(); +ListResponse firstPage = client.apiEndpoints().list( + new ListParams().setLimit(50) +); -for (var ep : result.getData()) { +for (APIEndpoint ep : firstPage.getData()) { System.out.println(ep.getFullyQualifiedName()); } // Filter by API collection with fields -var result = APIEndpoints.list() - .apiCollection("sample_api_service.pet") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var ep : result.getData()) { +ListResponse filtered = client.apiEndpoints().list( + new ListParams() + .addFilter("apiCollection", "sample_api_service.pet") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (APIEndpoint ep : filtered.getData()) { System.out.println(ep.getFullyQualifiedName()); } ``` @@ -196,7 +201,7 @@ Returns a paginated list of API endpoint objects. By default, only basic fields - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v2.0.x/api-reference/data-assets/api-endpoints/retrieve.mdx b/v2.0.x/api-reference/data-assets/api-endpoints/retrieve.mdx index d559c9ca2..c01ae707e 100644 --- a/v2.0.x/api-reference/data-assets/api-endpoints/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/api-endpoints/retrieve.mdx @@ -16,7 +16,7 @@ Get a single API endpoint by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single API endpoint by its unique ID or fully qualified name. Use `GET /v1/apiEndpoints/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the API endpoint (e.g., `sample_api_service.pet.addPet`). + Fully qualified name of the API endpoint, for example `sample_api_service.pet.addPet`. @@ -51,7 +51,7 @@ configure( # Get by ID ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c") -print(f"{ep.fullyQualifiedName}: {ep.description}") +print(f"{ep.fullyQualifiedName.root}: {ep.name.root}") # Get by ID with fields ep = APIEndpoints.retrieve( @@ -65,31 +65,33 @@ ep = APIEndpoints.retrieve_by_name("sample_api_service.pet.addPet") # Get by name with fields ep = APIEndpoints.retrieve_by_name( "sample_api_service.pet.addPet", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/apiEndpoints/{id} -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.schema.entity.data.APIEndpoint; + +// client is an initialized OpenMetadataClient. // Get by ID -var ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +APIEndpoint ep = client.apiEndpoints().get("1f61427a-4a64-4070-9ac8-1d29302dac7c"); // Get by ID with fields -var ep = APIEndpoints.retrieve( +APIEndpoint epWithFields = client.apiEndpoints().get( "1f61427a-4a64-4070-9ac8-1d29302dac7c", "owners,tags" ); // Get by fully qualified name -var ep = APIEndpoints.retrieveByName( +APIEndpoint epByName = client.apiEndpoints().getByName( "sample_api_service.pet.addPet" ); // Get by name with fields -var ep = APIEndpoints.retrieveByName( +APIEndpoint epByNameWithFields = client.apiEndpoints().getByName( "sample_api_service.pet.addPet", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -188,7 +190,7 @@ Returns an API endpoint object with all requested fields populated. - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -202,7 +204,7 @@ Returns an API endpoint object with all requested fields populated. - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -230,7 +232,7 @@ Returns an API endpoint object with all requested fields populated. - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v2.0.x/api-reference/data-assets/api-endpoints/update.mdx b/v2.0.x/api-reference/data-assets/api-endpoints/update.mdx index 595980a7c..456768692 100644 --- a/v2.0.x/api-reference/data-assets/api-endpoints/update.mdx +++ b/v2.0.x/api-reference/data-assets/api-endpoints/update.mdx @@ -20,7 +20,7 @@ Update an API endpoint's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/apiEndpoints/name/{fqn}` to update by fully qualified name. - Fully qualified name of the API endpoint (e.g., `sample_api_service.pet.addPet`). + Fully qualified name of the API endpoint, for example `sample_api_service.pet.addPet`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -62,7 +62,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -80,7 +80,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -94,17 +94,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -126,16 +126,18 @@ ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c") ep.description = "Updated: Add a new pet to the store inventory" updated = APIEndpoints.update(ep) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/apiEndpoints/{id} -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.schema.entity.data.APIEndpoint; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +APIEndpoint ep = client.apiEndpoints().get("1f61427a-4a64-4070-9ac8-1d29302dac7c"); ep.setDescription("Updated: Add a new pet to the store inventory"); -var updated = APIEndpoints.update(ep); +APIEndpoint updated = client.apiEndpoints().update("1f61427a-4a64-4070-9ac8-1d29302dac7c", ep); ``` ```bash PATCH /v1/apiEndpoints/{id} diff --git a/v2.0.x/api-reference/data-assets/api-endpoints/versions.mdx b/v2.0.x/api-reference/data-assets/api-endpoints/versions.mdx index 81d53a748..888cda388 100644 --- a/v2.0.x/api-reference/data-assets/api-endpoints/versions.mdx +++ b/v2.0.x/api-reference/data-assets/api-endpoints/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/apiEndpoints/{id}/versions/{version}` to retrieve a specific versio - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/apiEndpoints/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import APIEndpoints @@ -40,28 +42,30 @@ configure( # List all versions versions = APIEndpoints.get_versions("1f61427a-4a64-4070-9ac8-1d29302dac7c") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version ep_v1 = APIEndpoints.get_specific_version( "1f61427a-4a64-4070-9ac8-1d29302dac7c", "0.1" ) -print(f"Original description: {ep_v1.description}") +print(f"Original description: {ep_v1.description.root if ep_v1.description else None}") ``` ```java GET /v1/apiEndpoints/{id}/versions -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.schema.entity.data.APIEndpoint; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = APIEndpoints.getVersions("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +EntityHistory history = client.apiEndpoints().getVersionList("1f61427a-4a64-4070-9ac8-1d29302dac7c"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = APIEndpoints.getSpecificVersion( +APIEndpoint v1 = client.apiEndpoints().getVersion( "1f61427a-4a64-4070-9ac8-1d29302dac7c", 0.1 ); diff --git a/v2.0.x/api-reference/data-assets/charts/create.mdx b/v2.0.x/api-reference/data-assets/charts/create.mdx index 9846abb83..a113dcd46 100644 --- a/v2.0.x/api-reference/data-assets/charts/create.mdx +++ b/v2.0.x/api-reference/data-assets/charts/create.mdx @@ -16,7 +16,7 @@ Create a new chart within a dashboard service. - Fully qualified name of the parent DashboardService (e.g., `sample_superset`). + Fully qualified name of the parent DashboardService, for example `sample_superset`. @@ -44,7 +44,7 @@ Create a new chart within a dashboard service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -53,8 +53,8 @@ Create a new chart within a dashboard service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -66,11 +66,11 @@ Create a new chart within a dashboard service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -100,21 +100,25 @@ request = CreateChartRequest( ) chart = Charts.create(request) -print(f"Created: {chart.fullyQualifiedName}") +print(f"Created: {chart.fullyQualifiedName.root}") ``` ```java POST /v1/charts -import static org.openmetadata.sdk.fluent.Charts.*; - -// Create using builder pattern -var chart = Charts.builder() - .name("114") - .displayName("# of Games That Hit 100k in Sales By Release Year") - .service("sample_superset") - .description("Bar chart showing games that hit 100k in sales by release year") - .chartType("Other") - .sourceUrl("http://localhost:808/explore/?slice_id=114") - .create(); +import org.openmetadata.schema.api.data.CreateChart; +import org.openmetadata.schema.entity.data.Chart; +import org.openmetadata.schema.type.ChartType; + +// client is an initialized OpenMetadataClient. + +CreateChart request = new CreateChart() + .withName("114") + .withDisplayName("# of Games That Hit 100k in Sales By Release Year") + .withService("sample_superset") + .withDescription("Bar chart showing games that hit 100k in sales by release year") + .withChartType(ChartType.Other) + .withSourceUrl("http://localhost:808/explore/?slice_id=114"); + +Chart chart = client.charts().create(request); ``` ```bash POST /v1/charts @@ -196,7 +200,7 @@ Returns the created chart object with all specified properties and system-genera - Type of chart visualization (e.g., Line, Bar, Area, Pie, Scatter, Table, Histogram, Other). + Type of chart visualization, for example Line, Bar, Area, Pie, Scatter, Table, Histogram, Other. @@ -226,7 +230,7 @@ Returns the created chart object with all specified properties and system-genera - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. @@ -238,7 +242,7 @@ Returns the created chart object with all specified properties and system-genera - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -260,11 +264,11 @@ Returns the created chart object with all specified properties and system-genera - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/charts/delete.mdx b/v2.0.x/api-reference/data-assets/charts/delete.mdx index 22cd4cc29..ad6b2972c 100644 --- a/v2.0.x/api-reference/data-assets/charts/delete.mdx +++ b/v2.0.x/api-reference/data-assets/charts/delete.mdx @@ -28,7 +28,7 @@ Delete a chart by ID or fully qualified name. Supports soft delete (default), ha Use `DELETE /v1/charts/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the chart (e.g., `sample_superset.114`). + Fully qualified name of the chart, for example `sample_superset.114`. @@ -66,36 +66,40 @@ Charts.delete( hard_delete=True ) -# Delete by name -Charts.delete_by_name("sample_superset.114") +# Delete by name (look up the ID first) +entity = Charts.retrieve_by_name("sample_superset.114") +Charts.delete(entity.id) # Delete by name with options -Charts.delete_by_name( - "sample_superset.114", - hard_delete=True -) +entity = Charts.retrieve_by_name("sample_superset.114") +Charts.delete(entity.id, hard_delete=True) # Restore a soft-deleted chart Charts.restore("2dde4b53-a577-424b-bbaa-18ac32eca8a9") ``` ```java DELETE /v1/charts/{id} -import static org.openmetadata.sdk.fluent.Charts.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -Charts.delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9").execute(); +client.charts().delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); // Hard delete -Charts.delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9") - .hardDelete() - .execute(); +client.charts().delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9", Map.of("hardDelete", "true")); // Delete by name -Charts.deleteByName("sample_superset.114") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/charts/name/sample_superset.114", + null, + Void.class +); // Restore -Charts.restore("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +client.charts().restore("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); ``` ```bash DELETE /v1/charts/{id} diff --git a/v2.0.x/api-reference/data-assets/charts/list.mdx b/v2.0.x/api-reference/data-assets/charts/list.mdx index 87d2e7a08..1a941a61b 100644 --- a/v2.0.x/api-reference/data-assets/charts/list.mdx +++ b/v2.0.x/api-reference/data-assets/charts/list.mdx @@ -47,49 +47,54 @@ configure( # List first page charts = Charts.list(limit=50) -for c in charts.data: - print(f"{c.fullyQualifiedName}") +for c in charts.entities: + print(f"{c.fullyQualifiedName.root}") # List all with auto-pagination for c in Charts.list_all(): - print(f"{c.fullyQualifiedName}") + print(f"{c.fullyQualifiedName.root}") # Filter by service charts = Charts.list( - service="sample_superset", + filters={"service": "sample_superset"}, fields=["owners", "tags", "domains"], limit=50 ) -for c in charts.data: - print(f"{c.fullyQualifiedName} ({c.chartType})") +for c in charts.entities: + print(f"{c.fullyQualifiedName.root} ({c.chartType.value})") if c.owners: - print(f" Owners: {[o.name for o in c.owners]}") + print(f" Owners: {[o.name for o in c.owners.root]}") if c.tags: - print(f" Tags: {[t.tagFQN for t in c.tags]}") + print(f" Tags: {[t.tagFQN.root for t in c.tags]}") ``` ```java GET /v1/charts -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.Chart; + +// client is an initialized OpenMetadataClient. // List first page -var result = Charts.list() - .limit(50) - .execute(); +ListResponse firstPage = client.charts().list( + new ListParams().setLimit(50) +); -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +for (Chart chart : firstPage.getData()) { + System.out.println(chart.getFullyQualifiedName()); } // Filter by service with fields -var result = Charts.list() - .service("sample_superset") - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +ListResponse filtered = client.charts().list( + new ListParams() + .setService("sample_superset") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (Chart chart : filtered.getData()) { + System.out.println(chart.getFullyQualifiedName()); } ``` @@ -187,7 +192,7 @@ Returns a paginated list of chart objects. By default, only basic fields are inc - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.0.x/api-reference/data-assets/charts/retrieve.mdx b/v2.0.x/api-reference/data-assets/charts/retrieve.mdx index ddc8cb3c7..3fd56d77c 100644 --- a/v2.0.x/api-reference/data-assets/charts/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/charts/retrieve.mdx @@ -16,7 +16,7 @@ Get a single chart by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single chart by its unique ID or fully qualified name. Use `GET /v1/charts/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the chart (e.g., `sample_superset.114`). + Fully qualified name of the chart, for example `sample_superset.114`. @@ -51,7 +51,7 @@ configure( # Get by ID chart = Charts.retrieve("2dde4b53-a577-424b-bbaa-18ac32eca8a9") -print(f"{chart.fullyQualifiedName}: {chart.displayName}") +print(f"{chart.fullyQualifiedName.root}: {chart.displayName}") # Get by ID with fields chart = Charts.retrieve( @@ -70,22 +70,26 @@ chart = Charts.retrieve_by_name( ``` ```java GET /v1/charts/{id} -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.schema.entity.data.Chart; + +// client is an initialized OpenMetadataClient. // Get by ID -var chart = Charts.retrieve("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +Chart chart = client.charts().get("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); // Get by ID with fields -var chart = Charts.retrieve( +Chart chartWithFields = client.charts().get( "2dde4b53-a577-424b-bbaa-18ac32eca8a9", "owners,tags" ); // Get by fully qualified name -var chart = Charts.retrieveByName("sample_superset.114"); +Chart chartByName = client.charts().getByName( + "sample_superset.114" +); // Get by name with fields -var chart = Charts.retrieveByName( +Chart chartByNameWithFields = client.charts().getByName( "sample_superset.114", "owners,tags,domains" ); @@ -203,7 +207,7 @@ Returns a chart object with all requested fields populated. - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.0.x/api-reference/data-assets/charts/update.mdx b/v2.0.x/api-reference/data-assets/charts/update.mdx index 88b1254f1..781389c09 100644 --- a/v2.0.x/api-reference/data-assets/charts/update.mdx +++ b/v2.0.x/api-reference/data-assets/charts/update.mdx @@ -20,7 +20,7 @@ Update a chart's properties using JSON Merge Patch. You can update by ID or by f Use `PATCH /v1/charts/name/{fqn}` to update by fully qualified name. - Fully qualified name of the chart (e.g., `sample_superset.114`). + Fully qualified name of the chart, for example `sample_superset.114`. ## Body Parameters @@ -52,7 +52,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,17 +66,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -99,16 +99,18 @@ chart.description = "Updated: Bar chart showing top-selling games by release yea chart.chartType = "Bar" updated = Charts.update(chart) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/charts/{id} -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.schema.entity.data.Chart; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var chart = Charts.retrieve("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +Chart chart = client.charts().get("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); chart.setDescription("Updated: Bar chart showing top-selling games by release year"); -var updated = Charts.update(chart); +Chart updated = client.charts().update("2dde4b53-a577-424b-bbaa-18ac32eca8a9", chart); ``` ```bash PATCH /v1/charts/{id} diff --git a/v2.0.x/api-reference/data-assets/charts/versions.mdx b/v2.0.x/api-reference/data-assets/charts/versions.mdx index 879d3da3f..3fbe2d8f1 100644 --- a/v2.0.x/api-reference/data-assets/charts/versions.mdx +++ b/v2.0.x/api-reference/data-assets/charts/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/charts/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/charts/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Charts @@ -40,28 +42,30 @@ configure( # List all versions versions = Charts.get_versions("2dde4b53-a577-424b-bbaa-18ac32eca8a9") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version chart_v1 = Charts.get_specific_version( "2dde4b53-a577-424b-bbaa-18ac32eca8a9", "0.1" ) -print(f"Original description: {chart_v1.description}") +print(f"Original description: {chart_v1.description.root if chart_v1.description else None}") ``` ```java GET /v1/charts/{id}/versions -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.schema.entity.data.Chart; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Charts.getVersions("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +EntityHistory history = client.charts().getVersionList("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = Charts.getSpecificVersion( +Chart v1 = client.charts().getVersion( "2dde4b53-a577-424b-bbaa-18ac32eca8a9", 0.1 ); diff --git a/v2.0.x/api-reference/data-assets/containers/create.mdx b/v2.0.x/api-reference/data-assets/containers/create.mdx index 1bd5340b9..67f0fb641 100644 --- a/v2.0.x/api-reference/data-assets/containers/create.mdx +++ b/v2.0.x/api-reference/data-assets/containers/create.mdx @@ -16,7 +16,7 @@ Create a new container within a storage service. - Fully qualified name of the parent StorageService (e.g., `s3_datalake`). + Fully qualified name of the parent StorageService, for example `s3_datalake`. @@ -42,7 +42,7 @@ Create a new container within a storage service. - Path prefix for objects in the container (e.g., `/raw/events/`). + Path prefix for objects in the container, for example `/raw/events/`. @@ -54,7 +54,7 @@ Create a new container within a storage service. - List of file formats stored in the container (e.g., `csv`, `tsv`, `parquet`, `avro`, `json`, `jsonl`, `jsonGz`, `jsonZip`). + List of file formats stored in the container, for example `csv`, `tsv`, `parquet`, `avro`, `json`, `jsonl`, `jsonGz`, `jsonZip`. @@ -74,7 +74,7 @@ Create a new container within a storage service. - Data type (e.g., `STRING`, `INT`, `DOUBLE`, `TIMESTAMP`). + Data type, for example `STRING`, `INT`, `DOUBLE`, `TIMESTAMP`. @@ -86,7 +86,7 @@ Create a new container within a storage service. - Full path of the container (e.g., `s3://analytics-bucket/raw/events`). + Full path of the container, for example `s3://analytics-bucket/raw/events`. @@ -98,7 +98,7 @@ Create a new container within a storage service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -107,8 +107,8 @@ Create a new container within a storage service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -120,11 +120,11 @@ Create a new container within a storage service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -165,23 +165,28 @@ request = CreateContainerRequest( ) container = Containers.create(request) -print(f"Created: {container.fullyQualifiedName}") +print(f"Created: {container.fullyQualifiedName.root}") ``` ```java POST /v1/containers -import static org.openmetadata.sdk.fluent.Containers.*; - -// Create using builder pattern -var container = Containers.builder() - .name("analytics-bucket") - .displayName("Analytics Bucket") - .service("s3_datalake") - .description("Primary analytics data lake bucket") - .prefix("/analytics/") - .numberOfObjects(150000) - .size(5368709120L) - .fileFormats("parquet", "json") - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateContainer; +import org.openmetadata.schema.entity.data.Container; +import org.openmetadata.schema.type.ContainerFileFormat; + +// client is an initialized OpenMetadataClient. + +CreateContainer request = new CreateContainer() + .withName("analytics-bucket") + .withDisplayName("Analytics Bucket") + .withService("s3_datalake") + .withDescription("Primary analytics data lake bucket") + .withPrefix("/analytics/") + .withNumberOfObjects(150000.0) + .withSize(5368709120.0) + .withFileFormats(List.of(ContainerFileFormat.Parquet, ContainerFileFormat.Json)); + +Container container = client.containers().create(request); ``` ```bash POST /v1/containers @@ -307,7 +312,7 @@ Returns the created container object with all specified properties and system-ge - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -353,7 +358,7 @@ Returns the created container object with all specified properties and system-ge - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -375,11 +380,11 @@ Returns the created container object with all specified properties and system-ge - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/containers/delete.mdx b/v2.0.x/api-reference/data-assets/containers/delete.mdx index 6e7ec2f34..dc3560e11 100644 --- a/v2.0.x/api-reference/data-assets/containers/delete.mdx +++ b/v2.0.x/api-reference/data-assets/containers/delete.mdx @@ -28,7 +28,7 @@ Delete a container by ID or fully qualified name. Supports soft delete (default) Use `DELETE /v1/containers/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the container (e.g., `s3_datalake.analytics-bucket`). + Fully qualified name of the container, for example `s3_datalake.analytics-bucket`. @@ -66,36 +66,40 @@ Containers.delete( hard_delete=True ) -# Delete by name -Containers.delete_by_name("s3_datalake.analytics-bucket") +# Delete by name (look up the ID first) +entity = Containers.retrieve_by_name("s3_datalake.analytics-bucket") +Containers.delete(entity.id) # Delete by name with options -Containers.delete_by_name( - "s3_datalake.analytics-bucket", - hard_delete=True, - recursive=True -) +entity = Containers.retrieve_by_name("s3_datalake.analytics-bucket") +Containers.delete(entity.id, hard_delete=True, recursive=True) # Restore a soft-deleted container Containers.restore("14744329-85c2-499e-b1fa-249fb8162341") ``` ```java DELETE /v1/containers/{id} -import static org.openmetadata.sdk.fluent.Containers.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -Containers.delete("14744329-85c2-499e-b1fa-249fb8162341").execute(); +client.containers().delete("14744329-85c2-499e-b1fa-249fb8162341"); // Hard delete -Containers.delete("14744329-85c2-499e-b1fa-249fb8162341") - .hardDelete() - .execute(); +client.containers().delete("14744329-85c2-499e-b1fa-249fb8162341", Map.of("hardDelete", "true")); // Delete by name -Containers.deleteByName("s3_datalake.analytics-bucket").execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/containers/name/s3_datalake.analytics-bucket", + null, + Void.class +); // Restore -Containers.restore("14744329-85c2-499e-b1fa-249fb8162341"); +client.containers().restore("14744329-85c2-499e-b1fa-249fb8162341"); ``` ```bash DELETE /v1/containers/{id} diff --git a/v2.0.x/api-reference/data-assets/containers/list.mdx b/v2.0.x/api-reference/data-assets/containers/list.mdx index 49abe6bbe..a50a0ef38 100644 --- a/v2.0.x/api-reference/data-assets/containers/list.mdx +++ b/v2.0.x/api-reference/data-assets/containers/list.mdx @@ -28,7 +28,7 @@ List all containers with optional filtering and pagination. - Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `children`, `sourceHash`. See [Supported Fields](#supported-fields) below. + Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `sourceHash`. See [Supported Fields](#supported-fields) below. @@ -47,49 +47,54 @@ configure( # List first page containers = Containers.list(limit=50) -for c in containers.data: - print(f"{c.fullyQualifiedName}") +for c in containers.entities: + print(f"{c.fullyQualifiedName.root}") # List all with auto-pagination for c in Containers.list_all(): - print(f"{c.fullyQualifiedName}") + print(f"{c.fullyQualifiedName.root}") # Filter by storage service containers = Containers.list( - service="s3_datalake", + filters={"service": "s3_datalake"}, fields=["owners", "tags", "dataModel"], limit=50 ) -for c in containers.data: - print(f"{c.fullyQualifiedName}") +for c in containers.entities: + print(f"{c.fullyQualifiedName.root}") if c.owners: - print(f" Owners: {[o.name for o in c.owners]}") + print(f" Owners: {[o.name for o in c.owners.root]}") if c.tags: - print(f" Tags: {[t.tagFQN for t in c.tags]}") + print(f" Tags: {[t.tagFQN.root for t in c.tags]}") ``` ```java GET /v1/containers -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.Container; + +// client is an initialized OpenMetadataClient. // List first page -var result = Containers.list() - .limit(50) - .execute(); +ListResponse firstPage = client.containers().list( + new ListParams().setLimit(50) +); -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +for (Container container : firstPage.getData()) { + System.out.println(container.getFullyQualifiedName()); } -// Filter by storage service with fields -var result = Containers.list() - .service("s3_datalake") - .fields("owners", "tags", "dataModel") - .limit(50) - .execute(); +// Filter by service with fields +ListResponse filtered = client.containers().list( + new ListParams() + .setService("s3_datalake") + .setFields("owners,tags,dataModel") + .setLimit(50) +); -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +for (Container container : filtered.getData()) { + System.out.println(container.getFullyQualifiedName()); } ``` @@ -103,7 +108,7 @@ curl "{base_url}/api/v1/containers?service=s3_datalake&limit=50" \ -H "Authorization: Bearer {access_token}" # With fields -curl "{base_url}/api/v1/containers?service=s3_datalake&fields=owners,tags,dataModel,children&limit=50" \ +curl "{base_url}/api/v1/containers?service=s3_datalake&fields=owners,tags,dataModel&limit=50" \ -H "Authorization: Bearer {access_token}" ``` @@ -186,7 +191,7 @@ Returns a paginated list of container objects. By default, only basic fields are - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -229,10 +234,6 @@ Returns a paginated list of container objects. By default, only basic fields are Data model describing the schema of files. Only included when `fields` contains `dataModel`. - - Nested child containers. Only included when `fields` contains `children`. - - Custom properties. Only included when `fields` contains `extension`. @@ -272,7 +273,6 @@ The following fields can be requested via the `fields` query parameter: | `extension` | Custom property values | | `domains` | Domain assignments for governance | | `dataModel` | Data model with column definitions | -| `children` | Nested child containers | | `sourceHash` | Hash for change detection | --- diff --git a/v2.0.x/api-reference/data-assets/containers/retrieve.mdx b/v2.0.x/api-reference/data-assets/containers/retrieve.mdx index cdd8cebd7..ba7e84161 100644 --- a/v2.0.x/api-reference/data-assets/containers/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/containers/retrieve.mdx @@ -16,7 +16,7 @@ Get a single container by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,dataModel,children,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,dataModel,sourceHash`. @@ -28,11 +28,11 @@ Get a single container by its unique ID or fully qualified name. Use `GET /v1/containers/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the container (e.g., `s3_datalake.analytics-bucket`). + Fully qualified name of the container, for example `s3_datalake.analytics-bucket`. - Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `children`, `sourceHash`. + Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `sourceHash`. @@ -51,12 +51,12 @@ configure( # Get by ID container = Containers.retrieve("14744329-85c2-499e-b1fa-249fb8162341") -print(f"{container.fullyQualifiedName}: {container.description}") +print(f"{container.fullyQualifiedName.root}: {container.name.root}") # Get by ID with fields container = Containers.retrieve( "14744329-85c2-499e-b1fa-249fb8162341", - fields=["owners", "tags", "dataModel", "children"] + fields=["owners", "tags", "dataModel"] ) # Get by fully qualified name @@ -65,29 +65,33 @@ container = Containers.retrieve_by_name("s3_datalake.analytics-bucket") # Get by name with fields container = Containers.retrieve_by_name( "s3_datalake.analytics-bucket", - fields=["owners", "tags", "dataModel", "children"] + fields=["owners", "tags", "dataModel"] ) ``` ```java GET /v1/containers/{id} -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.schema.entity.data.Container; + +// client is an initialized OpenMetadataClient. // Get by ID -var container = Containers.retrieve("14744329-85c2-499e-b1fa-249fb8162341"); +Container container = client.containers().get("14744329-85c2-499e-b1fa-249fb8162341"); // Get by ID with fields -var container = Containers.retrieve( +Container containerWithFields = client.containers().get( "14744329-85c2-499e-b1fa-249fb8162341", - "owners,tags,dataModel,children" + "owners,tags,dataModel" ); // Get by fully qualified name -var container = Containers.retrieveByName("s3_datalake.analytics-bucket"); +Container containerByName = client.containers().getByName( + "s3_datalake.analytics-bucket" +); // Get by name with fields -var container = Containers.retrieveByName( +Container containerByNameWithFields = client.containers().getByName( "s3_datalake.analytics-bucket", - "owners,tags,dataModel,children" + "owners,tags,dataModel" ); ``` @@ -97,7 +101,7 @@ curl "{base_url}/api/v1/containers/14744329-85c2-499e-b1fa-249fb8162341" \ -H "Authorization: Bearer {access_token}" # Get by ID with fields -curl "{base_url}/api/v1/containers/14744329-85c2-499e-b1fa-249fb8162341?fields=owners,tags,dataModel,children" \ +curl "{base_url}/api/v1/containers/14744329-85c2-499e-b1fa-249fb8162341?fields=owners,tags,dataModel" \ -H "Authorization: Bearer {access_token}" # Get by fully qualified name @@ -105,7 +109,7 @@ curl "{base_url}/api/v1/containers/name/s3_datalake.analytics-bucket" \ -H "Authorization: Bearer {access_token}" # Get by name with fields -curl "{base_url}/api/v1/containers/name/s3_datalake.analytics-bucket?fields=owners,tags,dataModel,children" \ +curl "{base_url}/api/v1/containers/name/s3_datalake.analytics-bucket?fields=owners,tags,dataModel" \ -H "Authorization: Bearer {access_token}" ``` @@ -207,7 +211,7 @@ Returns a container object with all requested fields populated. - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -224,10 +228,6 @@ Returns a container object with all requested fields populated. - - Nested child containers. Only included when `fields` contains `children`. - - Version number for the entity. diff --git a/v2.0.x/api-reference/data-assets/containers/update.mdx b/v2.0.x/api-reference/data-assets/containers/update.mdx index 7e81596ae..a968da596 100644 --- a/v2.0.x/api-reference/data-assets/containers/update.mdx +++ b/v2.0.x/api-reference/data-assets/containers/update.mdx @@ -20,7 +20,7 @@ Update a container's properties using JSON Merge Patch. You can update by ID or Use `PATCH /v1/containers/name/{fqn}` to update by fully qualified name. - Fully qualified name of the container (e.g., `s3_datalake.analytics-bucket`). + Fully qualified name of the container, for example `s3_datalake.analytics-bucket`. ## Body Parameters @@ -74,7 +74,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -88,17 +88,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -122,16 +122,18 @@ container.numberOfObjects = 175000 container.size = 6442450944 updated = Containers.update(container) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/containers/{id} -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.schema.entity.data.Container; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var container = Containers.retrieve("14744329-85c2-499e-b1fa-249fb8162341"); +Container container = client.containers().get("14744329-85c2-499e-b1fa-249fb8162341"); container.setDescription("Updated: Primary analytics bucket with partitioned parquet data"); -var updated = Containers.update(container); +Container updated = client.containers().update("14744329-85c2-499e-b1fa-249fb8162341", container); ``` ```bash PATCH /v1/containers/{id} diff --git a/v2.0.x/api-reference/data-assets/containers/versions.mdx b/v2.0.x/api-reference/data-assets/containers/versions.mdx index 0a21c1351..711b51e0f 100644 --- a/v2.0.x/api-reference/data-assets/containers/versions.mdx +++ b/v2.0.x/api-reference/data-assets/containers/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/containers/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/containers/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Containers @@ -40,28 +42,30 @@ configure( # List all versions versions = Containers.get_versions("14744329-85c2-499e-b1fa-249fb8162341") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version container_v1 = Containers.get_specific_version( "14744329-85c2-499e-b1fa-249fb8162341", "0.1" ) -print(f"Original description: {container_v1.description}") +print(f"Original description: {container_v1.description.root if container_v1.description else None}") ``` ```java GET /v1/containers/{id}/versions -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.schema.entity.data.Container; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Containers.getVersions("14744329-85c2-499e-b1fa-249fb8162341"); +EntityHistory history = client.containers().getVersionList("14744329-85c2-499e-b1fa-249fb8162341"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = Containers.getSpecificVersion( +Container v1 = client.containers().getVersion( "14744329-85c2-499e-b1fa-249fb8162341", 0.1 ); diff --git a/v2.0.x/api-reference/data-assets/dashboard-services/create.mdx b/v2.0.x/api-reference/data-assets/dashboard-services/create.mdx index 71cb5b5cb..480b48640 100644 --- a/v2.0.x/api-reference/data-assets/dashboard-services/create.mdx +++ b/v2.0.x/api-reference/data-assets/dashboard-services/create.mdx @@ -16,7 +16,7 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Type of dashboard service (e.g., `Superset`, `Looker`, `Tableau`, `Metabase`, `Redash`, `PowerBI`, `Mode`, `QlikSense`, `QlikCloud`, `Lightdash`, `DomoDashboard`, `CustomDashboard`). + Type of dashboard service, for example `Superset`, `Looker`, `Tableau`, `Metabase`, `Redash`, `PowerBI`, `Mode`, `QlikSense`, `QlikCloud`, `Lightdash`, `DomoDashboard`, `CustomDashboard`. @@ -32,7 +32,7 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Service-specific connection configuration (e.g., hostPort, username, password for Superset). + Service-specific connection configuration, for example hostPort, username, password for Superset. @@ -46,7 +46,7 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new dashboard service connection to a platform such as Superset, Looker - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -112,16 +112,26 @@ print(f"Created: {service['fullyQualifiedName']}") ``` ```java POST /v1/services/dashboardServices -import static org.openmetadata.sdk.fluent.DashboardServices.*; - -DashboardService service = DashboardServices.builder() - .name("sample_looker") - .serviceType("Looker") - .connection(lookerConnection() - .clientId("your-client-id") - .clientSecret("***") - .hostPort("https://looker.example.com:443")) - .create(); +import org.openmetadata.schema.api.data.CreateDashboardDataModel.DashboardServiceType; +import org.openmetadata.schema.api.services.CreateDashboardService; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.schema.services.connections.dashboard.LookerConnection; +import org.openmetadata.schema.type.DashboardConnection; +import org.openmetadata.sdk.fluent.DashboardServices; +import java.net.URI; + +CreateDashboardService request = new CreateDashboardService() + .withName("sample_looker") + .withDisplayName("Sample Looker") + .withServiceType(DashboardServiceType.Looker) + .withDescription("Production Looker instance") + .withConnection(new DashboardConnection().withConfig( + new LookerConnection() + .withClientId("your-client-id") + .withClientSecret("***") + .withHostPort(URI.create("https://looker.example.com:443")))); + +DashboardService service = DashboardServices.create(request); ``` ```bash POST /v1/services/dashboardServices @@ -201,7 +211,7 @@ Returns the created dashboard service object with all specified properties and s - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. @@ -223,7 +233,7 @@ Returns the created dashboard service object with all specified properties and s - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -232,7 +242,7 @@ Returns the created dashboard service object with all specified properties and s - + Fully qualified name of the assigned domain. @@ -245,11 +255,11 @@ Returns the created dashboard service object with all specified properties and s - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/dashboard-services/delete.mdx b/v2.0.x/api-reference/data-assets/dashboard-services/delete.mdx index de55ba160..d5885b92e 100644 --- a/v2.0.x/api-reference/data-assets/dashboard-services/delete.mdx +++ b/v2.0.x/api-reference/data-assets/dashboard-services/delete.mdx @@ -28,7 +28,7 @@ Delete a dashboard service by ID or fully qualified name. Supports soft delete ( Use `DELETE /v1/services/dashboardServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. @@ -84,7 +84,10 @@ response = requests.put( ``` ```java DELETE /v1/services/dashboardServices/{id} -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.fluent.DashboardServices; + +// client is an initialized OpenMetadataClient. // Soft delete DashboardServices.delete("2c0c7c05-d820-4bea-a471-047deb7f92fd").execute(); @@ -94,11 +97,12 @@ DashboardServices.delete("2c0c7c05-d820-4bea-a471-047deb7f92fd") .hardDelete() .execute(); -// Delete by name -DashboardServices.deleteByName("sample_looker").execute(); +// Delete by name (look up the ID first) +DashboardService service = DashboardServices.retrieveByName("sample_looker"); +DashboardServices.delete(service.getId()).execute(); -// Restore -DashboardServices.restore("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +// Restore. The fluent class has no restore method, so use the client service. +client.dashboardServices().restore("2c0c7c05-d820-4bea-a471-047deb7f92fd"); ``` ```bash DELETE /v1/services/dashboardServices/{id} diff --git a/v2.0.x/api-reference/data-assets/dashboard-services/import-export.mdx b/v2.0.x/api-reference/data-assets/dashboard-services/import-export.mdx index 338b3d2db..04fdd6f38 100644 --- a/v2.0.x/api-reference/data-assets/dashboard-services/import-export.mdx +++ b/v2.0.x/api-reference/data-assets/dashboard-services/import-export.mdx @@ -14,7 +14,7 @@ Export dashboard service metadata (dashboards, charts, owners, tags) to CSV and `GET /v1/services/dashboardServices/name/{fqn}/export` - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. ## Export Async @@ -88,38 +88,6 @@ response = requests.put( ) ``` -```java GET /v1/services/dashboardServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.DashboardServices; - -// Synchronous export -String csvData = DashboardServices.exportCsv("sample_looker") - .execute(); - -// Async export -String jobId = DashboardServices.exportCsv("sample_looker") - .async() - .execute(); - -// Synchronous import (dry run) -String result = DashboardServices.importCsv("sample_looker") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = DashboardServices.importCsv("sample_looker") - .withData(csvData) - .dryRun(false) - .execute(); - -// Async import -String jobId = DashboardServices.importCsv("sample_looker") - .withData(csvData) - .dryRun(false) - .async() - .execute(); -``` - ```bash GET /v1/services/dashboardServices/name/{fqn}/export # Export to CSV curl "{base_url}/api/v1/services/dashboardServices/name/sample_looker/export" \ diff --git a/v2.0.x/api-reference/data-assets/dashboard-services/list.mdx b/v2.0.x/api-reference/data-assets/dashboard-services/list.mdx index b5bbfb9a6..3bae0ef39 100644 --- a/v2.0.x/api-reference/data-assets/dashboard-services/list.mdx +++ b/v2.0.x/api-reference/data-assets/dashboard-services/list.mdx @@ -59,22 +59,23 @@ response = requests.get( ``` ```java GET /v1/services/dashboardServices -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = DashboardServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.dashboardServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (DashboardService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } // With fields -var result = DashboardServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); +ListResponse withFields = client.dashboardServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/dashboardServices @@ -144,7 +145,7 @@ Returns a paginated list of dashboard service objects. By default, only basic fi - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.0.x/api-reference/data-assets/dashboard-services/retrieve.mdx b/v2.0.x/api-reference/data-assets/dashboard-services/retrieve.mdx index 2aba0a945..0703ad50a 100644 --- a/v2.0.x/api-reference/data-assets/dashboard-services/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/dashboard-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single dashboard service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single dashboard service by its unique ID or fully qualified name. Use `GET /v1/services/dashboardServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. @@ -71,22 +71,23 @@ response = requests.get( ``` ```java GET /v1/services/dashboardServices/{id} -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.fluent.DashboardServices; // Get by ID -var svc = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +DashboardService service = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); // Get by ID with fields -var svc = DashboardServices.retrieve( +DashboardService serviceWithFields = DashboardServices.retrieve( "2c0c7c05-d820-4bea-a471-047deb7f92fd", "owners,tags,domains" ); // Get by fully qualified name -var svc = DashboardServices.retrieveByName("sample_looker"); +DashboardService serviceByName = DashboardServices.retrieveByName("sample_looker"); // Get by name with fields -var svc = DashboardServices.retrieveByName("sample_looker", "owners,tags,domains"); +DashboardService serviceByNameWithFields = DashboardServices.retrieveByName("sample_looker", "owners,tags,domains"); ``` ```bash GET /v1/services/dashboardServices/{id} @@ -156,7 +157,7 @@ Returns a dashboard service object with all requested fields populated. - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. diff --git a/v2.0.x/api-reference/data-assets/dashboard-services/update.mdx b/v2.0.x/api-reference/data-assets/dashboard-services/update.mdx index 902695aa5..f9a9defc4 100644 --- a/v2.0.x/api-reference/data-assets/dashboard-services/update.mdx +++ b/v2.0.x/api-reference/data-assets/dashboard-services/update.mdx @@ -20,7 +20,7 @@ Update a dashboard service's properties using JSON Merge Patch. You can update b Use `PATCH /v1/services/dashboardServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -108,12 +108,13 @@ print(f"Updated to version {service['version']}") ``` ```java PATCH /v1/services/dashboardServices/{id} -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.fluent.DashboardServices; // Retrieve, modify, and update -var svc = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); -svc.setDescription("Updated Looker production instance"); -var updated = DashboardServices.update(svc); +DashboardService service = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +service.setDescription("Updated Looker production instance"); +DashboardService updated = DashboardServices.update(service); ``` ```bash PATCH /v1/services/dashboardServices/{id} diff --git a/v2.0.x/api-reference/data-assets/dashboard-services/versions.mdx b/v2.0.x/api-reference/data-assets/dashboard-services/versions.mdx index c9b41cc49..9f92d6666 100644 --- a/v2.0.x/api-reference/data-assets/dashboard-services/versions.mdx +++ b/v2.0.x/api-reference/data-assets/dashboard-services/versions.mdx @@ -24,7 +24,7 @@ Use `GET /v1/services/dashboardServices/{id}/versions/{version}` to retrieve a s - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. @@ -54,20 +54,20 @@ response = requests.get( ``` ```java GET /v1/services/dashboardServices/{id}/versions -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = DashboardServices.getVersions("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +EntityHistory history = client.dashboardServices().getVersionList("2c0c7c05-d820-4bea-a471-047deb7f92fd"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = DashboardServices.getSpecificVersion( - "2c0c7c05-d820-4bea-a471-047deb7f92fd", - 0.1 -); +DashboardService v1 = client.dashboardServices().getVersion("2c0c7c05-d820-4bea-a471-047deb7f92fd", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/dashboards/create.mdx b/v2.0.x/api-reference/data-assets/dashboards/create.mdx index 28db09886..94d7c821d 100644 --- a/v2.0.x/api-reference/data-assets/dashboards/create.mdx +++ b/v2.0.x/api-reference/data-assets/dashboards/create.mdx @@ -16,7 +16,7 @@ Create a new dashboard within a dashboard service. - Fully qualified name of the parent DashboardService (e.g., `sample_superset`). + Fully qualified name of the parent DashboardService, for example `sample_superset`. @@ -44,7 +44,7 @@ Create a new dashboard within a dashboard service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -53,8 +53,8 @@ Create a new dashboard within a dashboard service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -66,11 +66,11 @@ Create a new dashboard within a dashboard service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -99,20 +99,23 @@ request = CreateDashboardRequest( ) dashboard = Dashboards.create(request) -print(f"Created: {dashboard.fullyQualifiedName}") +print(f"Created: {dashboard.fullyQualifiedName.root}") ``` ```java POST /v1/dashboards -import static org.openmetadata.sdk.fluent.Dashboards.*; - -// Create using builder pattern -var dashboard = Dashboards.builder() - .name("10") - .displayName("deck.gl Demo") - .service("sample_superset") - .description("Dashboard showcasing deck.gl visualizations") - .sourceUrl("http://localhost:808/superset/dashboard/10/") - .create(); +import org.openmetadata.schema.api.data.CreateDashboard; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. + +CreateDashboard request = new CreateDashboard() + .withName("10") + .withDisplayName("deck.gl Demo") + .withService("sample_superset") + .withDescription("Dashboard showcasing deck.gl visualizations") + .withSourceUrl("http://localhost:808/superset/dashboard/10/"); + +Dashboard dashboard = client.dashboards().create(request); ``` ```bash POST /v1/dashboards @@ -219,7 +222,7 @@ Returns the created dashboard object with all specified properties and system-ge - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. @@ -235,7 +238,7 @@ Returns the created dashboard object with all specified properties and system-ge - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -257,11 +260,11 @@ Returns the created dashboard object with all specified properties and system-ge - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/dashboards/delete.mdx b/v2.0.x/api-reference/data-assets/dashboards/delete.mdx index fdff6d9f5..0fce19cce 100644 --- a/v2.0.x/api-reference/data-assets/dashboards/delete.mdx +++ b/v2.0.x/api-reference/data-assets/dashboards/delete.mdx @@ -28,7 +28,7 @@ Delete a dashboard by ID or fully qualified name. Supports soft delete (default) Use `DELETE /v1/dashboards/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the dashboard (e.g., `sample_superset.10`). + Fully qualified name of the dashboard, for example `sample_superset.10`. @@ -66,36 +66,40 @@ Dashboards.delete( hard_delete=True ) -# Delete by name -Dashboards.delete_by_name("sample_superset.10") +# Delete by name (look up the ID first) +entity = Dashboards.retrieve_by_name("sample_superset.10") +Dashboards.delete(entity.id) # Delete by name with options -Dashboards.delete_by_name( - "sample_superset.10", - hard_delete=True -) +entity = Dashboards.retrieve_by_name("sample_superset.10") +Dashboards.delete(entity.id, hard_delete=True) # Restore a soft-deleted dashboard Dashboards.restore("03fb5cc3-de48-423f-9926-8e192e5de59d") ``` ```java DELETE /v1/dashboards/{id} -import static org.openmetadata.sdk.fluent.Dashboards.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -Dashboards.delete("03fb5cc3-de48-423f-9926-8e192e5de59d").execute(); +client.dashboards().delete("03fb5cc3-de48-423f-9926-8e192e5de59d"); // Hard delete -Dashboards.delete("03fb5cc3-de48-423f-9926-8e192e5de59d") - .hardDelete() - .execute(); +client.dashboards().delete("03fb5cc3-de48-423f-9926-8e192e5de59d", Map.of("hardDelete", "true")); // Delete by name -Dashboards.deleteByName("sample_superset.10") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/dashboards/name/sample_superset.10", + null, + Void.class +); // Restore -Dashboards.restore("03fb5cc3-de48-423f-9926-8e192e5de59d"); +client.dashboards().restore("03fb5cc3-de48-423f-9926-8e192e5de59d"); ``` ```bash DELETE /v1/dashboards/{id} diff --git a/v2.0.x/api-reference/data-assets/dashboards/followers-votes.mdx b/v2.0.x/api-reference/data-assets/dashboards/followers-votes.mdx index d13baa472..686650713 100644 --- a/v2.0.x/api-reference/data-assets/dashboards/followers-votes.mdx +++ b/v2.0.x/api-reference/data-assets/dashboards/followers-votes.mdx @@ -51,7 +51,7 @@ Manage followers and votes for dashboard entities. ```python PUT /v1/dashboards/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Dashboards configure( @@ -59,39 +59,62 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + dashboard_id = "03fb5cc3-de48-423f-9926-8e192e5de59d" user_id = "user-uuid-here" # Add a follower dashboard = Dashboards.add_followers(dashboard_id, [user_id]) -print(f"Followers: {len(dashboard.followers)}") +print(f"Followers: {len(dashboard.followers.root)}") # Remove a follower dashboard = Dashboards.remove_followers(dashboard_id, [user_id]) # Add a vote -dashboard = Dashboards.add_vote(dashboard_id, vote_type="votedUp") +rest.put(f"/dashboards/{dashboard_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -dashboard = Dashboards.remove_vote(dashboard_id) +rest.put(f"/dashboards/{dashboard_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/dashboards/{id}/followers -import static org.openmetadata.sdk.fluent.Dashboards.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String dashboardId = "03fb5cc3-de48-423f-9926-8e192e5de59d"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; // Add a follower -Dashboards.addFollower(dashboardId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/dashboards/" + dashboardId + "/followers", + UUID.fromString(userId) +); // Remove a follower -Dashboards.removeFollower(dashboardId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/dashboards/" + dashboardId + "/followers/" + userId, + null +); // Add a vote -Dashboards.vote(dashboardId, "votedUp"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/dashboards/" + dashboardId + "/vote", + Map.of("updatedVoteType", "votedUp") +); // Remove a vote -Dashboards.vote(dashboardId, "unVoted"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/dashboards/" + dashboardId + "/vote", + Map.of("updatedVoteType", "unVoted") +); ``` ```bash PUT /v1/dashboards/{id}/followers diff --git a/v2.0.x/api-reference/data-assets/dashboards/list.mdx b/v2.0.x/api-reference/data-assets/dashboards/list.mdx index 70171ee6e..22fc27e9a 100644 --- a/v2.0.x/api-reference/data-assets/dashboards/list.mdx +++ b/v2.0.x/api-reference/data-assets/dashboards/list.mdx @@ -47,49 +47,54 @@ configure( # List first page dashboards = Dashboards.list(limit=50) -for d in dashboards.data: - print(f"{d.fullyQualifiedName}") +for d in dashboards.entities: + print(f"{d.fullyQualifiedName.root}") # List all with auto-pagination for d in Dashboards.list_all(): - print(f"{d.fullyQualifiedName}") + print(f"{d.fullyQualifiedName.root}") # Filter by service dashboards = Dashboards.list( - service="sample_superset", + filters={"service": "sample_superset"}, fields=["owners", "tags", "charts"], limit=50 ) -for d in dashboards.data: - print(f"{d.fullyQualifiedName}") +for d in dashboards.entities: + print(f"{d.fullyQualifiedName.root}") if d.owners: - print(f" Owners: {[o.name for o in d.owners]}") + print(f" Owners: {[o.name for o in d.owners.root]}") if d.tags: - print(f" Tags: {[t.tagFQN for t in d.tags]}") + print(f" Tags: {[t.tagFQN.root for t in d.tags]}") ``` ```java GET /v1/dashboards -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. // List first page -var result = Dashboards.list() - .limit(50) - .execute(); +ListResponse firstPage = client.dashboards().list( + new ListParams().setLimit(50) +); -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +for (Dashboard dashboard : firstPage.getData()) { + System.out.println(dashboard.getFullyQualifiedName()); } // Filter by service with fields -var result = Dashboards.list() - .service("sample_superset") - .fields("owners", "tags", "charts") - .limit(50) - .execute(); - -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +ListResponse filtered = client.dashboards().list( + new ListParams() + .setService("sample_superset") + .setFields("owners,tags,charts") + .setLimit(50) +); + +for (Dashboard dashboard : filtered.getData()) { + System.out.println(dashboard.getFullyQualifiedName()); } ``` @@ -191,7 +196,7 @@ Returns a paginated list of dashboard objects. By default, only basic fields are - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.0.x/api-reference/data-assets/dashboards/retrieve.mdx b/v2.0.x/api-reference/data-assets/dashboards/retrieve.mdx index 482070f33..75f6f4246 100644 --- a/v2.0.x/api-reference/data-assets/dashboards/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/dashboards/retrieve.mdx @@ -16,7 +16,7 @@ Get a single dashboard by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,charts,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,charts,sourceHash`. @@ -28,7 +28,7 @@ Get a single dashboard by its unique ID or fully qualified name. Use `GET /v1/dashboards/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the dashboard (e.g., `sample_superset.10`). + Fully qualified name of the dashboard, for example `sample_superset.10`. @@ -51,7 +51,7 @@ configure( # Get by ID dashboard = Dashboards.retrieve("03fb5cc3-de48-423f-9926-8e192e5de59d") -print(f"{dashboard.fullyQualifiedName}: {dashboard.displayName}") +print(f"{dashboard.fullyQualifiedName.root}: {dashboard.displayName}") # Get by ID with fields dashboard = Dashboards.retrieve( @@ -70,22 +70,26 @@ dashboard = Dashboards.retrieve_by_name( ``` ```java GET /v1/dashboards/{id} -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. // Get by ID -var dashboard = Dashboards.retrieve("03fb5cc3-de48-423f-9926-8e192e5de59d"); +Dashboard dashboard = client.dashboards().get("03fb5cc3-de48-423f-9926-8e192e5de59d"); // Get by ID with fields -var dashboard = Dashboards.retrieve( +Dashboard dashboardWithFields = client.dashboards().get( "03fb5cc3-de48-423f-9926-8e192e5de59d", "owners,tags,charts" ); // Get by fully qualified name -var dashboard = Dashboards.retrieveByName("sample_superset.10"); +Dashboard dashboardByName = client.dashboards().getByName( + "sample_superset.10" +); // Get by name with fields -var dashboard = Dashboards.retrieveByName( +Dashboard dashboardByNameWithFields = client.dashboards().getByName( "sample_superset.10", "owners,tags,charts,domains" ); @@ -207,7 +211,7 @@ Returns a dashboard object with all requested fields populated. - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.0.x/api-reference/data-assets/dashboards/update.mdx b/v2.0.x/api-reference/data-assets/dashboards/update.mdx index 58fa8be74..9da6c6d1f 100644 --- a/v2.0.x/api-reference/data-assets/dashboards/update.mdx +++ b/v2.0.x/api-reference/data-assets/dashboards/update.mdx @@ -20,7 +20,7 @@ Update a dashboard's properties using JSON Merge Patch. You can update by ID or Use `PATCH /v1/dashboards/name/{fqn}` to update by fully qualified name. - Fully qualified name of the dashboard (e.g., `sample_superset.10`). + Fully qualified name of the dashboard, for example `sample_superset.10`. ## Body Parameters @@ -52,7 +52,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,17 +66,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -99,16 +99,18 @@ dashboard.description = "Updated: deck.gl Demo dashboard with new visualizations dashboard.displayName = "deck.gl Demo v2" updated = Dashboards.update(dashboard) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dashboards/{id} -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var dashboard = Dashboards.retrieve("03fb5cc3-de48-423f-9926-8e192e5de59d"); +Dashboard dashboard = client.dashboards().get("03fb5cc3-de48-423f-9926-8e192e5de59d"); dashboard.setDescription("Updated: deck.gl Demo dashboard with new visualizations"); -var updated = Dashboards.update(dashboard); +Dashboard updated = client.dashboards().update("03fb5cc3-de48-423f-9926-8e192e5de59d", dashboard); ``` ```bash PATCH /v1/dashboards/{id} diff --git a/v2.0.x/api-reference/data-assets/dashboards/versions.mdx b/v2.0.x/api-reference/data-assets/dashboards/versions.mdx index 4bce3046b..bc288b1f2 100644 --- a/v2.0.x/api-reference/data-assets/dashboards/versions.mdx +++ b/v2.0.x/api-reference/data-assets/dashboards/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dashboards/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dashboards/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Dashboards @@ -40,28 +42,30 @@ configure( # List all versions versions = Dashboards.get_versions("03fb5cc3-de48-423f-9926-8e192e5de59d") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version dashboard_v1 = Dashboards.get_specific_version( "03fb5cc3-de48-423f-9926-8e192e5de59d", "0.1" ) -print(f"Original description: {dashboard_v1.description}") +print(f"Original description: {dashboard_v1.description.root if dashboard_v1.description else None}") ``` ```java GET /v1/dashboards/{id}/versions -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.schema.entity.data.Dashboard; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Dashboards.getVersions("03fb5cc3-de48-423f-9926-8e192e5de59d"); +EntityHistory history = client.dashboards().getVersionList("03fb5cc3-de48-423f-9926-8e192e5de59d"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = Dashboards.getSpecificVersion( +Dashboard v1 = client.dashboards().getVersion( "03fb5cc3-de48-423f-9926-8e192e5de59d", 0.1 ); diff --git a/v2.0.x/api-reference/data-assets/database-schemas/advanced.mdx b/v2.0.x/api-reference/data-assets/database-schemas/advanced.mdx index b446aa8d4..fd8eb9e08 100644 --- a/v2.0.x/api-reference/data-assets/database-schemas/advanced.mdx +++ b/v2.0.x/api-reference/data-assets/database-schemas/advanced.mdx @@ -53,19 +53,19 @@ Manage followers, votes, and profiler configuration for database schema entities ### Get Profiler Config -`GET /v1/databaseSchemas/{id}/profilerConfig` +`GET /v1/databaseSchemas/{id}/databaseSchemaProfilerConfig` ### Set Profiler Config -`PUT /v1/databaseSchemas/{id}/profilerConfig` +`PUT /v1/databaseSchemas/{id}/databaseSchemaProfilerConfig` ### Delete Profiler Config -`DELETE /v1/databaseSchemas/{id}/profilerConfig` +`DELETE /v1/databaseSchemas/{id}/databaseSchemaProfilerConfig` ```python PUT /v1/databaseSchemas/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import DatabaseSchemas configure( @@ -73,27 +73,30 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + schema_id = "770e8400-e29b-41d4-a716-446655440000" user_id = "user-uuid-here" # Add a follower schema = DatabaseSchemas.add_followers(schema_id, [user_id]) -print(f"Followers: {len(schema.followers)}") +print(f"Followers: {len(schema.followers.root)}") # Remove a follower schema = DatabaseSchemas.remove_followers(schema_id, [user_id]) # Add a vote -schema = DatabaseSchemas.add_vote(schema_id, vote_type="votedUp") +rest.put(f"/databaseSchemas/{schema_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -schema = DatabaseSchemas.remove_vote(schema_id) +rest.put(f"/databaseSchemas/{schema_id}/vote", json={"updatedVoteType": "unVoted"}) # Get profiler config -config = DatabaseSchemas.get_profiler_config(schema_id) +schema = DatabaseSchemas.retrieve(schema_id, fields=["databaseSchemaProfilerConfig"]) +print(schema.databaseSchemaProfilerConfig) # Set profiler config -DatabaseSchemas.set_profiler_config(schema_id, { +rest.put(f"/databaseSchemas/{schema_id}/databaseSchemaProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": { @@ -105,17 +108,72 @@ DatabaseSchemas.set_profiler_config(schema_id, { }) # Delete profiler config -DatabaseSchemas.delete_profiler_config(schema_id) +rest.delete(f"/databaseSchemas/{schema_id}/databaseSchemaProfilerConfig") ``` ```java PUT /v1/databaseSchemas/{id}/followers -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.schema.type.DatabaseSchemaProfilerConfig; +import org.openmetadata.sdk.network.HttpMethod; -String schemaId = "770e8400-e29b-41d4-a716-446655440000"; +// client is an initialized OpenMetadataClient. -// Followers - use REST client directly -// Votes and profiler config - use REST client directly -// See curl examples for request format +String schemaId = "770e8400-e29b-41d4-a716-446655440000"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; + +// Add a follower +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/followers", + UUID.fromString(userId) +); + +// Remove a follower +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databaseSchemas/" + schemaId + "/followers/" + userId, + null +); + +// Add a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/vote", + Map.of("updatedVoteType", "votedUp") +); + +// Remove a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/vote", + Map.of("updatedVoteType", "unVoted") +); + +// Get profiler config +DatabaseSchema schema = client.databaseSchemas().get(schemaId, "databaseSchemaProfilerConfig"); +DatabaseSchemaProfilerConfig profilerConfig = schema.getDatabaseSchemaProfilerConfig(); + +// Set profiler config +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/databaseSchemaProfilerConfig", + Map.of( + "profileSampleConfig", Map.of( + "sampleConfigType", "STATIC", + "config", Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE") + ), + "sampleDataCount", 200 + ) +); + +// Delete profiler config +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databaseSchemas/" + schemaId + "/databaseSchemaProfilerConfig", + null +); ``` ```bash PUT /v1/databaseSchemas/{id}/followers @@ -142,11 +200,11 @@ curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5 -d '{"updatedVoteType": "unVoted"}' # Get profiler config -curl "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/profilerConfig" \ +curl "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/databaseSchemaProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Set profiler config -curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/profilerConfig" \ +curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/databaseSchemaProfilerConfig" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -161,7 +219,7 @@ curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5 }' # Delete profiler config -curl -X DELETE "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/profilerConfig" \ +curl -X DELETE "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/databaseSchemaProfilerConfig" \ -H "Authorization: Bearer {access_token}" ``` diff --git a/v2.0.x/api-reference/data-assets/database-schemas/create.mdx b/v2.0.x/api-reference/data-assets/database-schemas/create.mdx index aadc7cf93..41ee04af9 100644 --- a/v2.0.x/api-reference/data-assets/database-schemas/create.mdx +++ b/v2.0.x/api-reference/data-assets/database-schemas/create.mdx @@ -28,7 +28,7 @@ Create a new database schema within a database. - Data retention period in ISO 8601 duration format (e.g., `P365D`). + Data retention period in ISO 8601 duration format, for example `P365D`. @@ -40,7 +40,7 @@ Create a new database schema within a database. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -49,8 +49,8 @@ Create a new database schema within a database. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -62,11 +62,11 @@ Create a new database schema within a database. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -95,15 +95,16 @@ request = CreateDatabaseSchemaRequest( ) schema = DatabaseSchemas.create(request) -print(f"Created: {schema.fullyQualifiedName}") +print(f"Created: {schema.fullyQualifiedName.root}") ``` ```java POST /v1/databaseSchemas -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.sdk.fluent.builders.DatabaseSchemaBuilder; -DatabaseSchema schema = DatabaseSchemas.builder() +DatabaseSchema schema = new DatabaseSchemaBuilder(client) .name("public") - .database("snowflake_prod.analytics") + .databaseFQN("snowflake_prod.analytics") .create(); ``` @@ -229,7 +230,7 @@ Returns the created database schema object with all specified properties and sys - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -245,7 +246,7 @@ Returns the created database schema object with all specified properties and sys - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -267,11 +268,11 @@ Returns the created database schema object with all specified properties and sys - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/database-schemas/delete.mdx b/v2.0.x/api-reference/data-assets/database-schemas/delete.mdx index 2cc2da242..ef90c0938 100644 --- a/v2.0.x/api-reference/data-assets/database-schemas/delete.mdx +++ b/v2.0.x/api-reference/data-assets/database-schemas/delete.mdx @@ -28,7 +28,7 @@ Delete a database schema by ID or fully qualified name. Supports soft delete (de Use `DELETE /v1/databaseSchemas/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the schema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the schema, for example `snowflake_prod.analytics.public`. @@ -67,31 +67,28 @@ DatabaseSchemas.delete( hard_delete=True ) -# Delete by name -DatabaseSchemas.delete_by_name("snowflake_prod.analytics.public") +# Delete by name (look up the ID first) +entity = DatabaseSchemas.retrieve_by_name("snowflake_prod.analytics.public") +DatabaseSchemas.delete(entity.id) # Delete by name with options -DatabaseSchemas.delete_by_name( - "snowflake_prod.analytics.public", - recursive=True, - hard_delete=True -) +entity = DatabaseSchemas.retrieve_by_name("snowflake_prod.analytics.public") +DatabaseSchemas.delete(entity.id, recursive=True, hard_delete=True) # Restore a soft-deleted schema DatabaseSchemas.restore("770e8400-e29b-41d4-a716-446655440000") ``` ```java DELETE /v1/databaseSchemas/{id} -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. // Soft delete -DatabaseSchemas.delete("770e8400-e29b-41d4-a716-446655440000").execute(); +client.databaseSchemas().delete("770e8400-e29b-41d4-a716-446655440000"); // Hard delete with recursive -DatabaseSchemas.delete("770e8400-e29b-41d4-a716-446655440000") - .recursive() - .hardDelete() - .execute(); +client.databaseSchemas().delete("770e8400-e29b-41d4-a716-446655440000", Map.of("recursive", "true", "hardDelete", "true")); ``` ```bash DELETE /v1/databaseSchemas/{id} diff --git a/v2.0.x/api-reference/data-assets/database-schemas/import-export.mdx b/v2.0.x/api-reference/data-assets/database-schemas/import-export.mdx index 7c1e7ffe5..a9237a69d 100644 --- a/v2.0.x/api-reference/data-assets/database-schemas/import-export.mdx +++ b/v2.0.x/api-reference/data-assets/database-schemas/import-export.mdx @@ -14,7 +14,7 @@ Export database schema metadata (tables, owners, tags) to CSV and import changes `GET /v1/databaseSchemas/name/{fqn}/export` - Fully qualified name of the schema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the schema, for example `snowflake_prod.analytics.public`. ## Export Async @@ -88,17 +88,19 @@ result = ( ```java GET /v1/databaseSchemas/name/{fqn}/export import org.openmetadata.sdk.fluent.DatabaseSchemas; +DatabaseSchemas.setDefaultClient(client); + // Synchronous export String csvData = DatabaseSchemas.exportCsv("snowflake_prod.analytics.public") .execute(); // Async export -String jobId = DatabaseSchemas.exportCsv("snowflake_prod.analytics.public") +String exportJobId = DatabaseSchemas.exportCsv("snowflake_prod.analytics.public") .async() .execute(); // Synchronous import (dry run) -String result = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") +String dryRunResult = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") .withData(csvData) .dryRun(true) .execute(); @@ -110,7 +112,7 @@ String result = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") .execute(); // Async import -String jobId = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") +String importJobId = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") .withData(csvData) .dryRun(false) .async() diff --git a/v2.0.x/api-reference/data-assets/database-schemas/list.mdx b/v2.0.x/api-reference/data-assets/database-schemas/list.mdx index 3ced4ae73..cace5799f 100644 --- a/v2.0.x/api-reference/data-assets/database-schemas/list.mdx +++ b/v2.0.x/api-reference/data-assets/database-schemas/list.mdx @@ -52,27 +52,32 @@ configure( # List with pagination page = DatabaseSchemas.list(limit=50, fields=["owners", "tags"]) for s in page.entities: - print(f"{s.fullyQualifiedName}") + print(f"{s.fullyQualifiedName.root}") if s.owners: - print(f" Owners: {[o.name for o in s.owners]}") + print(f" Owners: {[o.name for o in s.owners.root]}") # List all with auto-pagination all_schemas = DatabaseSchemas.list_all(batch_size=100) for schema in all_schemas: - print(f"{schema.fullyQualifiedName}") + print(f"{schema.fullyQualifiedName.root}") ``` ```java GET /v1/databaseSchemas -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // Retrieve by ID -DatabaseSchema schema = DatabaseSchemas.retrieve(schemaId); +DatabaseSchema schema = client.databaseSchemas().get(schemaId); // List schemas -var result = DatabaseSchemas.list() - .fields("owners", "tags") - .limit(50) - .execute(); +ListResponse result = client.databaseSchemas().list( + new ListParams() + .setFields("owners,tags") + .setLimit(50) +); for (DatabaseSchema s : result.getData()) { System.out.println(s.getFullyQualifiedName()); @@ -206,7 +211,7 @@ Returns a paginated list of database schema objects. By default, only basic fiel - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.0.x/api-reference/data-assets/database-schemas/retrieve.mdx b/v2.0.x/api-reference/data-assets/database-schemas/retrieve.mdx index 5a4efdad7..d2ac7976b 100644 --- a/v2.0.x/api-reference/data-assets/database-schemas/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/database-schemas/retrieve.mdx @@ -28,7 +28,7 @@ Get a single database schema by its unique ID or fully qualified name. Use `GET /v1/databaseSchemas/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the schema (e.g., `Glue.default.information_schema`). + Fully qualified name of the schema, for example `Glue.default.information_schema`. @@ -51,7 +51,7 @@ configure( # Get by ID schema = DatabaseSchemas.retrieve("770e8400-e29b-41d4-a716-446655440000") -print(f"{schema.fullyQualifiedName}: {schema.description}") +print(f"{schema.fullyQualifiedName.root}: {schema.name.root}") # Get by ID with fields schema = DatabaseSchemas.retrieve( @@ -65,18 +65,20 @@ schema = DatabaseSchemas.retrieve_by_name("snowflake_prod.analytics.public") # Get by name with fields schema = DatabaseSchemas.retrieve_by_name( "snowflake_prod.analytics.public", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/databaseSchemas/{id} -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; + +// client is an initialized OpenMetadataClient. // Get by ID -DatabaseSchema schema = DatabaseSchemas.retrieve("770e8400-e29b-41d4-a716-446655440000"); +DatabaseSchema schema = client.databaseSchemas().get("770e8400-e29b-41d4-a716-446655440000"); // Get by fully qualified name -DatabaseSchema schema = DatabaseSchemas.retrieveByName("snowflake_prod.analytics.public"); +DatabaseSchema schemaByName = client.databaseSchemas().getByName("snowflake_prod.analytics.public"); ``` ```bash GET /v1/databaseSchemas/{id} @@ -230,7 +232,7 @@ Returns a database schema object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.0.x/api-reference/data-assets/database-schemas/update.mdx b/v2.0.x/api-reference/data-assets/database-schemas/update.mdx index 360f5b1e3..2df2cd726 100644 --- a/v2.0.x/api-reference/data-assets/database-schemas/update.mdx +++ b/v2.0.x/api-reference/data-assets/database-schemas/update.mdx @@ -20,7 +20,7 @@ Update a database schema's properties using JSON Merge Patch. You can update by Use `PATCH /v1/databaseSchemas/name/{fqn}` to update by fully qualified name. - Fully qualified name of the schema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the schema, for example `snowflake_prod.analytics.public`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,11 +58,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -71,8 +71,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. Updated retention period in ISO 8601 duration format. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -95,16 +95,18 @@ schema.description = "Updated public schema for analytics" schema.retentionPeriod = "P730D" updated = DatabaseSchemas.update(schema) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/databaseSchemas/{id} -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -DatabaseSchema schema = DatabaseSchemas.retrieve("770e8400-e29b-41d4-a716-446655440000"); +DatabaseSchema schema = client.databaseSchemas().get("770e8400-e29b-41d4-a716-446655440000"); schema.setDescription("Updated public schema for analytics"); -DatabaseSchema updated = DatabaseSchemas.update(schema); +DatabaseSchema updated = client.databaseSchemas().update("770e8400-e29b-41d4-a716-446655440000", schema); ``` ```bash PATCH /v1/databaseSchemas/{id} diff --git a/v2.0.x/api-reference/data-assets/database-schemas/versions.mdx b/v2.0.x/api-reference/data-assets/database-schemas/versions.mdx index 076951d20..57d2608eb 100644 --- a/v2.0.x/api-reference/data-assets/database-schemas/versions.mdx +++ b/v2.0.x/api-reference/data-assets/database-schemas/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/databaseSchemas/{id}/versions/{version}` to retrieve a specific ver - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/databaseSchemas/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import DatabaseSchemas @@ -40,26 +42,30 @@ configure( # List all versions versions = DatabaseSchemas.get_versions("770e8400-e29b-41d4-a716-446655440000") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version schema_v1 = DatabaseSchemas.get_specific_version( "770e8400-e29b-41d4-a716-446655440000", "0.1" ) -print(f"Original description: {schema_v1.description}") +print(f"Original description: {schema_v1.description.root if schema_v1.description else None}") ``` ```java GET /v1/databaseSchemas/{id}/versions -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = DatabaseSchemas.getVersions("770e8400-e29b-41d4-a716-446655440000"); +EntityHistory versions = client.databaseSchemas().getVersionList("770e8400-e29b-41d4-a716-446655440000"); // Get a specific version -DatabaseSchema v1 = DatabaseSchemas.getSpecificVersion( +DatabaseSchema v1 = client.databaseSchemas().getVersion( "770e8400-e29b-41d4-a716-446655440000", - "0.1" + 0.1 ); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/database-services/create.mdx b/v2.0.x/api-reference/data-assets/database-services/create.mdx index 06a17eafe..a6fff33ee 100644 --- a/v2.0.x/api-reference/data-assets/database-services/create.mdx +++ b/v2.0.x/api-reference/data-assets/database-services/create.mdx @@ -16,7 +16,7 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Type of database service (e.g., `Snowflake`, `BigQuery`, `PostgreSQL`, `MySQL`, `Redshift`, `Databricks`). + Type of database service, for example `Snowflake`, `BigQuery`, `PostgreSQL`, `MySQL`, `Redshift`, `Databricks`. @@ -32,7 +32,7 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Service-specific connection configuration (e.g., account, warehouse, database for Snowflake). + Service-specific connection configuration, for example account, warehouse, database for Snowflake. @@ -46,7 +46,7 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new database service connection to a platform such as Snowflake, BigQue - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -105,21 +105,30 @@ request = CreateDatabaseServiceRequest( ) service = DatabaseServices.create(request) -print(f"Created: {service.fullyQualifiedName}") +print(f"Created: {service.fullyQualifiedName.root}") ``` ```java POST /v1/services/databaseServices -import static org.openmetadata.sdk.fluent.DatabaseServices.*; - -DatabaseService service = DatabaseServices.builder() - .name("snowflake_prod") - .serviceType("Snowflake") - .connection(snowflakeConnection() - .account("xy12345.us-east-1") - .username("ingestion_user") - .warehouse("COMPUTE_WH") - .database("ANALYTICS")) - .create(); +import org.openmetadata.schema.api.services.CreateDatabaseService; +import org.openmetadata.schema.api.services.CreateDatabaseService.DatabaseServiceType; +import org.openmetadata.schema.api.services.DatabaseConnection; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.services.connections.database.SnowflakeConnection; +import org.openmetadata.sdk.fluent.DatabaseServices; + +CreateDatabaseService request = new CreateDatabaseService() + .withName("snowflake_prod") + .withServiceType(DatabaseServiceType.Snowflake) + .withDescription("Production Snowflake data warehouse") + .withConnection(new DatabaseConnection().withConfig( + new SnowflakeConnection() + .withAccount("xy12345.us-east-1") + .withUsername("ingestion_user") + .withPassword("***") + .withWarehouse("COMPUTE_WH") + .withDatabase("ANALYTICS"))); + +DatabaseService service = DatabaseServices.create(request); ``` ```bash POST /v1/services/databaseServices @@ -215,7 +224,7 @@ Returns the created database service object with all specified properties and sy - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -237,7 +246,7 @@ Returns the created database service object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -246,7 +255,7 @@ Returns the created database service object with all specified properties and sy - + Fully qualified name of the assigned domain. @@ -259,11 +268,11 @@ Returns the created database service object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/database-services/delete.mdx b/v2.0.x/api-reference/data-assets/database-services/delete.mdx index 771abdd2d..0c1aee2b1 100644 --- a/v2.0.x/api-reference/data-assets/database-services/delete.mdx +++ b/v2.0.x/api-reference/data-assets/database-services/delete.mdx @@ -28,7 +28,7 @@ Delete a database service by ID or fully qualified name. Supports soft delete (d Use `DELETE /v1/services/databaseServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. @@ -68,11 +68,11 @@ DatabaseServices.delete( ) # Delete by name -DatabaseServices.delete_by_name("snowflake_prod") +DatabaseServices.delete(DatabaseServices.retrieve_by_name("snowflake_prod").id) # Delete by name with options -DatabaseServices.delete_by_name( - "snowflake_prod", +DatabaseServices.delete( + DatabaseServices.retrieve_by_name("snowflake_prod").id, recursive=True, hard_delete=True ) @@ -82,7 +82,8 @@ DatabaseServices.restore("a1b2c3d4-e5f6-7890-abcd-ef1234567890") ``` ```java DELETE /v1/services/databaseServices/{id} -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.fluent.DatabaseServices; // Soft delete DatabaseServices.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890").execute(); diff --git a/v2.0.x/api-reference/data-assets/database-services/import-export.mdx b/v2.0.x/api-reference/data-assets/database-services/import-export.mdx index bfff3024c..925f07e5a 100644 --- a/v2.0.x/api-reference/data-assets/database-services/import-export.mdx +++ b/v2.0.x/api-reference/data-assets/database-services/import-export.mdx @@ -14,7 +14,7 @@ Export database service metadata (databases, schemas, owners, tags) to CSV and i `GET /v1/services/databaseServices/name/{fqn}/export` - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. ## Export Async @@ -86,35 +86,21 @@ result = ( ``` ```java GET /v1/services/databaseServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.DatabaseServices; - +// client is an initialized OpenMetadataClient. // Synchronous export -String csvData = DatabaseServices.exportCsv("snowflake_prod") - .execute(); +String csvData = client.databaseServices().exportCsv("snowflake_prod"); // Async export -String jobId = DatabaseServices.exportCsv("snowflake_prod") - .async() - .execute(); - -// Synchronous import (dry run) -String result = DatabaseServices.importCsv("snowflake_prod") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = DatabaseServices.importCsv("snowflake_prod") - .withData(csvData) - .dryRun(false) - .execute(); +String exportJob = client.databaseServices().exportCsvAsync("snowflake_prod"); + +// Import CSV (dry run first) +String dryRunResult = client.databaseServices().importCsv("snowflake_prod", csvData, true); + +// Apply the import +String result = client.databaseServices().importCsv("snowflake_prod", csvData, false); // Async import -String jobId = DatabaseServices.importCsv("snowflake_prod") - .withData(csvData) - .dryRun(false) - .async() - .execute(); +String importJob = client.databaseServices().importCsvAsync("snowflake_prod", csvData, false); ``` ```bash GET /v1/services/databaseServices/name/{fqn}/export diff --git a/v2.0.x/api-reference/data-assets/database-services/list.mdx b/v2.0.x/api-reference/data-assets/database-services/list.mdx index 5317ead18..305fe5109 100644 --- a/v2.0.x/api-reference/data-assets/database-services/list.mdx +++ b/v2.0.x/api-reference/data-assets/database-services/list.mdx @@ -48,31 +48,34 @@ configure( # List with pagination page = DatabaseServices.list(limit=50, fields=["owners", "tags"]) for svc in page.entities: - print(f"{svc.name} ({svc.serviceType})") + print(f"{svc.name.root} ({svc.serviceType})") if svc.owners: - print(f" Owners: {[o.name for o in svc.owners]}") + print(f" Owners: {[o.name for o in svc.owners.root]}") # List all with auto-pagination all_services = DatabaseServices.list_all(batch_size=100) for service in all_services: - print(f"{service.fullyQualifiedName}") + print(f"{service.fullyQualifiedName.root}") ``` ```java GET /v1/services/databaseServices -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; -// Retrieve by ID -DatabaseService service = DatabaseServices.retrieve(serviceId); +// client is an initialized OpenMetadataClient. -// List services -var result = DatabaseServices.list() - .fields("owners", "tags") - .limit(50) - .execute(); +// List first page +ListResponse firstPage = client.databaseServices().list(new ListParams().setLimit(50)); -for (DatabaseService svc : result.getData()) { - System.out.println(svc.getName() + " (" + svc.getServiceType() + ")"); +for (DatabaseService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } + +// With fields +ListResponse withFields = client.databaseServices().list( + new ListParams().setFields("owners,tags").setLimit(50) +); ``` ```bash GET /v1/services/databaseServices @@ -190,7 +193,7 @@ Returns a paginated list of database service objects. By default, only basic fie - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.0.x/api-reference/data-assets/database-services/retrieve.mdx b/v2.0.x/api-reference/data-assets/database-services/retrieve.mdx index 316fc13df..95fafb2cb 100644 --- a/v2.0.x/api-reference/data-assets/database-services/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/database-services/retrieve.mdx @@ -28,7 +28,7 @@ Get a single database service by its unique ID or fully qualified name. Use `GET /v1/services/databaseServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. @@ -51,7 +51,7 @@ configure( # Get by ID service = DatabaseServices.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890") -print(f"{service.fullyQualifiedName}: {service.serviceType}") +print(f"{service.fullyQualifiedName.root}: {service.serviceType}") # Get by ID with fields service = DatabaseServices.retrieve( @@ -65,18 +65,19 @@ service = DatabaseServices.retrieve_by_name("snowflake_prod") # Get by name with fields service = DatabaseServices.retrieve_by_name( "snowflake_prod", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/services/databaseServices/{id} -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.fluent.DatabaseServices; // Get by ID DatabaseService service = DatabaseServices.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Get by fully qualified name -DatabaseService service = DatabaseServices.retrieveByName("snowflake_prod"); +DatabaseService serviceByName = DatabaseServices.retrieveByName("snowflake_prod"); ``` ```bash GET /v1/services/databaseServices/{id} @@ -164,7 +165,7 @@ Returns a database service object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.0.x/api-reference/data-assets/database-services/update.mdx b/v2.0.x/api-reference/data-assets/database-services/update.mdx index 73829e8da..2a40b5461 100644 --- a/v2.0.x/api-reference/data-assets/database-services/update.mdx +++ b/v2.0.x/api-reference/data-assets/database-services/update.mdx @@ -20,7 +20,7 @@ Update a database service's properties using JSON Merge Patch. You can update by Use `PATCH /v1/services/databaseServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -97,11 +97,12 @@ service.description = "Updated production Snowflake warehouse" service.displayName = "Snowflake Prod (Updated)" updated = DatabaseServices.update(service) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/services/databaseServices/{id} -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.fluent.DatabaseServices; // Retrieve, modify, and update DatabaseService service = DatabaseServices.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); diff --git a/v2.0.x/api-reference/data-assets/database-services/versions.mdx b/v2.0.x/api-reference/data-assets/database-services/versions.mdx index e41aabe1b..ee1510466 100644 --- a/v2.0.x/api-reference/data-assets/database-services/versions.mdx +++ b/v2.0.x/api-reference/data-assets/database-services/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/services/databaseServices/{id}/versions/{version}` to retrieve a sp - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/services/databaseServices/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import DatabaseServices @@ -40,27 +42,32 @@ configure( # List all versions versions = DatabaseServices.get_versions("a1b2c3d4-e5f6-7890-abcd-ef1234567890") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version service_v1 = DatabaseServices.get_specific_version( "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "0.1" ) -print(f"Original description: {service_v1.description}") +print(f"Original description: {getattr(service_v1.description, 'root', service_v1.description)}") ``` ```java GET /v1/services/databaseServices/{id}/versions -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = DatabaseServices.getVersions("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +EntityHistory history = client.databaseServices().getVersionList("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); + +for (Object version : history.getVersions()) { + System.out.println("Version: " + version); +} // Get a specific version -DatabaseService v1 = DatabaseServices.getSpecificVersion( - "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "0.1" -); +DatabaseService v1 = client.databaseServices().getVersion("a1b2c3d4-e5f6-7890-abcd-ef1234567890", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/databases/advanced.mdx b/v2.0.x/api-reference/data-assets/databases/advanced.mdx index 9ae3b3f51..3f9bef554 100644 --- a/v2.0.x/api-reference/data-assets/databases/advanced.mdx +++ b/v2.0.x/api-reference/data-assets/databases/advanced.mdx @@ -53,19 +53,19 @@ Manage followers, votes, and profiler configuration for database entities. ### Get Profiler Config -`GET /v1/databases/{id}/profilerConfig` +`GET /v1/databases/{id}/databaseProfilerConfig` ### Set Profiler Config -`PUT /v1/databases/{id}/profilerConfig` +`PUT /v1/databases/{id}/databaseProfilerConfig` ### Delete Profiler Config -`DELETE /v1/databases/{id}/profilerConfig` +`DELETE /v1/databases/{id}/databaseProfilerConfig` ```python PUT /v1/databases/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Databases configure( @@ -73,27 +73,30 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + database_id = "550e8400-e29b-41d4-a716-446655440000" user_id = "user-uuid-here" # Add a follower database = Databases.add_followers(database_id, [user_id]) -print(f"Followers: {len(database.followers)}") +print(f"Followers: {len(database.followers.root)}") # Remove a follower database = Databases.remove_followers(database_id, [user_id]) # Add a vote -database = Databases.add_vote(database_id, vote_type="votedUp") +rest.put(f"/databases/{database_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -database = Databases.remove_vote(database_id) +rest.put(f"/databases/{database_id}/vote", json={"updatedVoteType": "unVoted"}) # Get profiler config -config = Databases.get_profiler_config(database_id) +database = Databases.retrieve(database_id, fields=["databaseProfilerConfig"]) +print(database.databaseProfilerConfig) # Set profiler config -Databases.set_profiler_config(database_id, { +rest.put(f"/databases/{database_id}/databaseProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": { @@ -105,17 +108,72 @@ Databases.set_profiler_config(database_id, { }) # Delete profiler config -Databases.delete_profiler_config(database_id) +rest.delete(f"/databases/{database_id}/databaseProfilerConfig") ``` ```java PUT /v1/databases/{id}/followers -import static org.openmetadata.sdk.fluent.Databases.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.schema.type.DatabaseProfilerConfig; +import org.openmetadata.sdk.network.HttpMethod; -String databaseId = "550e8400-e29b-41d4-a716-446655440000"; +// client is an initialized OpenMetadataClient. -// Followers - use REST client directly -// Votes and profiler config - use REST client directly -// See curl examples for request format +String databaseId = "550e8400-e29b-41d4-a716-446655440000"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; + +// Add a follower +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/followers", + UUID.fromString(userId) +); + +// Remove a follower +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databases/" + databaseId + "/followers/" + userId, + null +); + +// Add a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/vote", + Map.of("updatedVoteType", "votedUp") +); + +// Remove a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/vote", + Map.of("updatedVoteType", "unVoted") +); + +// Get profiler config +Database database = client.databases().get(databaseId, "databaseProfilerConfig"); +DatabaseProfilerConfig profilerConfig = database.getDatabaseProfilerConfig(); + +// Set profiler config +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/databaseProfilerConfig", + Map.of( + "profileSampleConfig", Map.of( + "sampleConfigType", "STATIC", + "config", Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE") + ), + "sampleDataCount", 200 + ) +); + +// Delete profiler config +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databases/" + databaseId + "/databaseProfilerConfig", + null +); ``` ```bash PUT /v1/databases/{id}/followers @@ -142,11 +200,11 @@ curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/vo -d '{"updatedVoteType": "unVoted"}' # Get profiler config -curl "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/profilerConfig" \ +curl "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/databaseProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Set profiler config -curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/profilerConfig" \ +curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/databaseProfilerConfig" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -161,7 +219,7 @@ curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/pr }' # Delete profiler config -curl -X DELETE "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/profilerConfig" \ +curl -X DELETE "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/databaseProfilerConfig" \ -H "Authorization: Bearer {access_token}" ``` diff --git a/v2.0.x/api-reference/data-assets/databases/create.mdx b/v2.0.x/api-reference/data-assets/databases/create.mdx index 104e9d412..a7bf8dbb5 100644 --- a/v2.0.x/api-reference/data-assets/databases/create.mdx +++ b/v2.0.x/api-reference/data-assets/databases/create.mdx @@ -28,7 +28,7 @@ Create a new database within a database service. - Data retention period in ISO 8601 duration format (e.g., `P365D`). + Data retention period in ISO 8601 duration format, for example `P365D`. @@ -40,7 +40,7 @@ Create a new database within a database service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -49,8 +49,8 @@ Create a new database within a database service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -62,11 +62,11 @@ Create a new database within a database service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -95,15 +95,16 @@ request = CreateDatabaseRequest( ) database = Databases.create(request) -print(f"Created: {database.fullyQualifiedName}") +print(f"Created: {database.fullyQualifiedName.root}") ``` ```java POST /v1/databases -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.sdk.fluent.builders.DatabaseBuilder; -Database database = Databases.builder() +Database database = new DatabaseBuilder(client) .name("analytics") - .service("snowflake_prod") + .serviceFQN("snowflake_prod") .create(); ``` @@ -201,7 +202,7 @@ Returns the created database object with all specified properties and system-gen - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -217,7 +218,7 @@ Returns the created database object with all specified properties and system-gen - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -226,7 +227,7 @@ Returns the created database object with all specified properties and system-gen - + Fully qualified name of the assigned domain. @@ -239,11 +240,11 @@ Returns the created database object with all specified properties and system-gen - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/databases/delete.mdx b/v2.0.x/api-reference/data-assets/databases/delete.mdx index d001ebc97..6078b6c5a 100644 --- a/v2.0.x/api-reference/data-assets/databases/delete.mdx +++ b/v2.0.x/api-reference/data-assets/databases/delete.mdx @@ -28,7 +28,7 @@ Delete a database by ID or fully qualified name. Supports soft delete (default), Use `DELETE /v1/databases/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the database (e.g., `snowflake_prod.analytics`). + Fully qualified name of the database, for example `snowflake_prod.analytics`. @@ -67,31 +67,28 @@ Databases.delete( hard_delete=True ) -# Delete by name -Databases.delete_by_name("snowflake_prod.analytics") +# Delete by name (look up the ID first) +entity = Databases.retrieve_by_name("snowflake_prod.analytics") +Databases.delete(entity.id) # Delete by name with options -Databases.delete_by_name( - "snowflake_prod.analytics", - recursive=True, - hard_delete=True -) +entity = Databases.retrieve_by_name("snowflake_prod.analytics") +Databases.delete(entity.id, recursive=True, hard_delete=True) # Restore a soft-deleted database Databases.restore("550e8400-e29b-41d4-a716-446655440000") ``` ```java DELETE /v1/databases/{id} -import static org.openmetadata.sdk.fluent.Databases.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. // Soft delete -Databases.delete("550e8400-e29b-41d4-a716-446655440000").execute(); +client.databases().delete("550e8400-e29b-41d4-a716-446655440000"); // Hard delete with recursive -Databases.delete("550e8400-e29b-41d4-a716-446655440000") - .recursive() - .hardDelete() - .execute(); +client.databases().delete("550e8400-e29b-41d4-a716-446655440000", Map.of("recursive", "true", "hardDelete", "true")); ``` ```bash DELETE /v1/databases/{id} diff --git a/v2.0.x/api-reference/data-assets/databases/import-export.mdx b/v2.0.x/api-reference/data-assets/databases/import-export.mdx index afd59678e..ce6cc0dbd 100644 --- a/v2.0.x/api-reference/data-assets/databases/import-export.mdx +++ b/v2.0.x/api-reference/data-assets/databases/import-export.mdx @@ -14,7 +14,7 @@ Export database metadata (schemas, tables, owners, tags) to CSV and import chang `GET /v1/databases/name/{fqn}/export` - Fully qualified name of the database (e.g., `snowflake_prod.analytics`). + Fully qualified name of the database, for example `snowflake_prod.analytics`. ## Export Async @@ -88,17 +88,19 @@ result = ( ```java GET /v1/databases/name/{fqn}/export import org.openmetadata.sdk.fluent.Databases; +Databases.setDefaultClient(client); + // Synchronous export String csvData = Databases.exportCsv("snowflake_prod.analytics") .execute(); // Async export -String jobId = Databases.exportCsv("snowflake_prod.analytics") +String exportJobId = Databases.exportCsv("snowflake_prod.analytics") .async() .execute(); // Synchronous import (dry run) -String result = Databases.importCsv("snowflake_prod.analytics") +String dryRunResult = Databases.importCsv("snowflake_prod.analytics") .withData(csvData) .dryRun(true) .execute(); @@ -110,7 +112,7 @@ String result = Databases.importCsv("snowflake_prod.analytics") .execute(); // Async import -String jobId = Databases.importCsv("snowflake_prod.analytics") +String importJobId = Databases.importCsv("snowflake_prod.analytics") .withData(csvData) .dryRun(false) .async() diff --git a/v2.0.x/api-reference/data-assets/databases/list.mdx b/v2.0.x/api-reference/data-assets/databases/list.mdx index 4fd9170c0..34ca00f2f 100644 --- a/v2.0.x/api-reference/data-assets/databases/list.mdx +++ b/v2.0.x/api-reference/data-assets/databases/list.mdx @@ -52,27 +52,32 @@ configure( # List with pagination page = Databases.list(limit=50, fields=["owners", "tags"]) for db in page.entities: - print(f"{db.fullyQualifiedName}") + print(f"{db.fullyQualifiedName.root}") if db.owners: - print(f" Owners: {[o.name for o in db.owners]}") + print(f" Owners: {[o.name for o in db.owners.root]}") # List all with auto-pagination all_databases = Databases.list_all(batch_size=100) for database in all_databases: - print(f"{database.fullyQualifiedName}") + print(f"{database.fullyQualifiedName.root}") ``` ```java GET /v1/databases -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // Retrieve by ID -Database database = Databases.retrieve(databaseId); +Database database = client.databases().get(databaseId); // List databases -var result = Databases.list() - .fields("owners", "tags") - .limit(50) - .execute(); +ListResponse result = client.databases().list( + new ListParams() + .setFields("owners,tags") + .setLimit(50) +); for (Database db : result.getData()) { System.out.println(db.getFullyQualifiedName()); @@ -181,7 +186,7 @@ Returns a paginated list of database objects. By default, only basic fields are - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -192,8 +197,8 @@ Returns a paginated list of database objects. By default, only basic fields are Classification tags applied to the database. Only included when `fields` contains `tags`. - - Domain assignment for governance. Only included when `fields` contains `domain`. + + Domain assignment for governance. Only included when `fields` contains `domains`. diff --git a/v2.0.x/api-reference/data-assets/databases/retrieve.mdx b/v2.0.x/api-reference/data-assets/databases/retrieve.mdx index 06132894b..75a554830 100644 --- a/v2.0.x/api-reference/data-assets/databases/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/databases/retrieve.mdx @@ -28,7 +28,7 @@ Get a single database by its unique ID or fully qualified name. Use `GET /v1/databases/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the database (e.g., `mysql_sample.default`). + Fully qualified name of the database, for example `mysql_sample.default`. @@ -51,7 +51,7 @@ configure( # Get by ID database = Databases.retrieve("550e8400-e29b-41d4-a716-446655440000") -print(f"{database.fullyQualifiedName}: {database.description}") +print(f"{database.fullyQualifiedName.root}: {database.name.root}") # Get by ID with fields database = Databases.retrieve( @@ -65,18 +65,20 @@ database = Databases.retrieve_by_name("snowflake_prod.analytics") # Get by name with fields database = Databases.retrieve_by_name( "snowflake_prod.analytics", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/databases/{id} -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; + +// client is an initialized OpenMetadataClient. // Get by ID -Database database = Databases.retrieve("550e8400-e29b-41d4-a716-446655440000"); +Database database = client.databases().get("550e8400-e29b-41d4-a716-446655440000"); // Get by fully qualified name -Database database = Databases.retrieveByName("snowflake_prod.analytics"); +Database databaseByName = client.databases().getByName("snowflake_prod.analytics"); ``` ```bash GET /v1/databases/{id} @@ -187,7 +189,7 @@ Returns a database object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -202,8 +204,8 @@ Returns a database object with all requested fields populated. Classification tags. Only included when `fields` contains `tags`. - - Domain assignment. Only included when `fields` contains `domain`. + + Domain assignment. Only included when `fields` contains `domains`. --- diff --git a/v2.0.x/api-reference/data-assets/databases/update.mdx b/v2.0.x/api-reference/data-assets/databases/update.mdx index 2c1492a8b..a18ad7e83 100644 --- a/v2.0.x/api-reference/data-assets/databases/update.mdx +++ b/v2.0.x/api-reference/data-assets/databases/update.mdx @@ -20,7 +20,7 @@ Update a database's properties using JSON Merge Patch. You can update by ID or b Use `PATCH /v1/databases/name/{fqn}` to update by fully qualified name. - Fully qualified name of the database (e.g., `snowflake_prod.analytics`). + Fully qualified name of the database, for example `snowflake_prod.analytics`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,11 +58,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -71,8 +71,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. Updated retention period in ISO 8601 duration format. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -95,16 +95,18 @@ database.description = "Updated analytics data warehouse" database.retentionPeriod = "P730D" updated = Databases.update(database) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/databases/{id} -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -Database database = Databases.retrieve("550e8400-e29b-41d4-a716-446655440000"); +Database database = client.databases().get("550e8400-e29b-41d4-a716-446655440000"); database.setDescription("Updated analytics data warehouse"); -Database updated = Databases.update(database); +Database updated = client.databases().update("550e8400-e29b-41d4-a716-446655440000", database); ``` ```bash PATCH /v1/databases/{id} diff --git a/v2.0.x/api-reference/data-assets/databases/versions.mdx b/v2.0.x/api-reference/data-assets/databases/versions.mdx index 536c721ce..af377eff8 100644 --- a/v2.0.x/api-reference/data-assets/databases/versions.mdx +++ b/v2.0.x/api-reference/data-assets/databases/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/databases/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/databases/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Databases @@ -40,26 +42,30 @@ configure( # List all versions versions = Databases.get_versions("550e8400-e29b-41d4-a716-446655440000") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version database_v1 = Databases.get_specific_version( "550e8400-e29b-41d4-a716-446655440000", "0.1" ) -print(f"Original description: {database_v1.description}") +print(f"Original description: {database_v1.description.root if database_v1.description else None}") ``` ```java GET /v1/databases/{id}/versions -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = Databases.getVersions("550e8400-e29b-41d4-a716-446655440000"); +EntityHistory versions = client.databases().getVersionList("550e8400-e29b-41d4-a716-446655440000"); // Get a specific version -Database v1 = Databases.getSpecificVersion( +Database v1 = client.databases().getVersion( "550e8400-e29b-41d4-a716-446655440000", - "0.1" + 0.1 ); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/messaging-services/create.mdx b/v2.0.x/api-reference/data-assets/messaging-services/create.mdx index 96bf6dabf..74298f429 100644 --- a/v2.0.x/api-reference/data-assets/messaging-services/create.mdx +++ b/v2.0.x/api-reference/data-assets/messaging-services/create.mdx @@ -16,7 +16,7 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Type of messaging service (e.g., `Kafka`, `Redpanda`, `Kinesis`, `CustomMessaging`). + Type of messaging service, for example `Kafka`, `Redpanda`, `Kinesis`, `CustomMessaging`. @@ -32,7 +32,7 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Service-specific connection configuration (e.g., bootstrapServers, securityProtocol for Kafka). + Service-specific connection configuration, for example bootstrapServers, securityProtocol for Kafka. @@ -46,7 +46,7 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -114,16 +114,22 @@ print(f"Created: {service['fullyQualifiedName']}") ``` ```java POST /v1/services/messagingServices -import static org.openmetadata.sdk.fluent.MessagingServices.*; - -MessagingService service = MessagingServices.builder() - .name("sample_kafka") - .serviceType("Kafka") - .connection(kafkaConnection() - .bootstrapServers("localhost:9092") - .securityProtocol("PLAINTEXT") - .saslMechanism("PLAIN")) - .create(); +import org.openmetadata.schema.api.services.CreateMessagingService; +import org.openmetadata.schema.api.services.CreateMessagingService.MessagingServiceType; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.schema.services.connections.messaging.KafkaConnection; +import org.openmetadata.schema.type.MessagingConnection; +import org.openmetadata.sdk.fluent.MessagingServices; + +CreateMessagingService request = new CreateMessagingService() + .withName("sample_kafka") + .withServiceType(MessagingServiceType.Kafka) + .withConnection(new MessagingConnection().withConfig( + new KafkaConnection() + .withBootstrapServers("localhost:9092") + .withSecurityProtocol(KafkaConnection.SecurityProtocol.PLAINTEXT))); + +MessagingService service = MessagingServices.create(request); ``` ```bash POST /v1/services/messagingServices @@ -206,7 +212,7 @@ Returns the created messaging service object with all specified properties and s - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. @@ -228,7 +234,7 @@ Returns the created messaging service object with all specified properties and s - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -237,7 +243,7 @@ Returns the created messaging service object with all specified properties and s - + Fully qualified name of the assigned domain. @@ -250,11 +256,11 @@ Returns the created messaging service object with all specified properties and s - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/messaging-services/delete.mdx b/v2.0.x/api-reference/data-assets/messaging-services/delete.mdx index c7a4bffb5..8310eaed0 100644 --- a/v2.0.x/api-reference/data-assets/messaging-services/delete.mdx +++ b/v2.0.x/api-reference/data-assets/messaging-services/delete.mdx @@ -28,7 +28,7 @@ Delete a messaging service by ID or fully qualified name. Supports soft delete ( Use `DELETE /v1/services/messagingServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. @@ -82,7 +82,8 @@ requests.put( ``` ```java DELETE /v1/services/messagingServices/{id} -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.fluent.MessagingServices; // Soft delete MessagingServices.delete("469ef25e-9bdf-4d5f-8553-eb0ce8581f30").execute(); diff --git a/v2.0.x/api-reference/data-assets/messaging-services/import-export.mdx b/v2.0.x/api-reference/data-assets/messaging-services/import-export.mdx index df1aadd09..58a7b937c 100644 --- a/v2.0.x/api-reference/data-assets/messaging-services/import-export.mdx +++ b/v2.0.x/api-reference/data-assets/messaging-services/import-export.mdx @@ -14,7 +14,7 @@ Export messaging service metadata (topics, owners, tags) to CSV and import chang `GET /v1/services/messagingServices/name/{fqn}/export` - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. ## Export Async @@ -90,38 +90,6 @@ response = requests.put( ) ``` -```java GET /v1/services/messagingServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.MessagingServices; - -// Synchronous export -String csvData = MessagingServices.exportCsv("sample_kafka") - .execute(); - -// Async export -String jobId = MessagingServices.exportCsv("sample_kafka") - .async() - .execute(); - -// Synchronous import (dry run) -String result = MessagingServices.importCsv("sample_kafka") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = MessagingServices.importCsv("sample_kafka") - .withData(csvData) - .dryRun(false) - .execute(); - -// Async import -String jobId = MessagingServices.importCsv("sample_kafka") - .withData(csvData) - .dryRun(false) - .async() - .execute(); -``` - ```bash GET /v1/services/messagingServices/name/{fqn}/export # Export to CSV curl "{base_url}/api/v1/services/messagingServices/name/sample_kafka/export" \ diff --git a/v2.0.x/api-reference/data-assets/messaging-services/list.mdx b/v2.0.x/api-reference/data-assets/messaging-services/list.mdx index a6d62e380..0595a9ead 100644 --- a/v2.0.x/api-reference/data-assets/messaging-services/list.mdx +++ b/v2.0.x/api-reference/data-assets/messaging-services/list.mdx @@ -61,17 +61,23 @@ response = requests.get( ``` ```java GET /v1/services/messagingServices -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; -// List services -var result = MessagingServices.list() - .fields("owners", "tags") - .limit(50) - .execute(); +// client is an initialized OpenMetadataClient. -for (MessagingService svc : result.getData()) { - System.out.println(svc.getName() + " (" + svc.getServiceType() + ")"); +// List first page +ListResponse firstPage = client.messagingServices().list(new ListParams().setLimit(50)); + +for (MessagingService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } + +// With fields +ListResponse withFields = client.messagingServices().list( + new ListParams().setFields("owners,tags").setLimit(50) +); ``` ```bash GET /v1/services/messagingServices @@ -155,7 +161,7 @@ Returns a paginated list of messaging service objects. By default, only basic fi - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v2.0.x/api-reference/data-assets/messaging-services/retrieve.mdx b/v2.0.x/api-reference/data-assets/messaging-services/retrieve.mdx index 8a164f3f8..eb445df61 100644 --- a/v2.0.x/api-reference/data-assets/messaging-services/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/messaging-services/retrieve.mdx @@ -28,7 +28,7 @@ Get a single messaging service by its unique ID or fully qualified name. Use `GET /v1/services/messagingServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. @@ -76,13 +76,23 @@ response = requests.get( ``` ```java GET /v1/services/messagingServices/{id} -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.fluent.MessagingServices; // Get by ID MessagingService service = MessagingServices.retrieve("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); +// Get by ID with fields +MessagingService serviceWithFields = MessagingServices.retrieve( + "469ef25e-9bdf-4d5f-8553-eb0ce8581f30", + "owners,tags" +); + // Get by fully qualified name -MessagingService service = MessagingServices.retrieveByName("sample_kafka"); +MessagingService serviceByName = MessagingServices.retrieveByName("sample_kafka"); + +// Get by name with fields +MessagingService serviceByNameWithFields = MessagingServices.retrieveByName("sample_kafka", "owners,tags"); ``` ```bash GET /v1/services/messagingServices/{id} @@ -162,7 +172,7 @@ Returns a messaging service object with all requested fields populated. - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v2.0.x/api-reference/data-assets/messaging-services/update.mdx b/v2.0.x/api-reference/data-assets/messaging-services/update.mdx index 5cd79add9..13b894550 100644 --- a/v2.0.x/api-reference/data-assets/messaging-services/update.mdx +++ b/v2.0.x/api-reference/data-assets/messaging-services/update.mdx @@ -20,7 +20,7 @@ Update a messaging service's properties using JSON Merge Patch. You can update b Use `PATCH /v1/services/messagingServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -105,7 +105,8 @@ print(f"Updated to version {updated['version']}") ``` ```java PATCH /v1/services/messagingServices/{id} -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.fluent.MessagingServices; // Retrieve, modify, and update MessagingService service = MessagingServices.retrieve("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); diff --git a/v2.0.x/api-reference/data-assets/messaging-services/versions.mdx b/v2.0.x/api-reference/data-assets/messaging-services/versions.mdx index 59bd8e175..80c748e35 100644 --- a/v2.0.x/api-reference/data-assets/messaging-services/versions.mdx +++ b/v2.0.x/api-reference/data-assets/messaging-services/versions.mdx @@ -24,7 +24,7 @@ Use `GET /v1/services/messagingServices/{id}/versions/{version}` to retrieve a s - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. @@ -53,16 +53,20 @@ print(f"Original description: {service_v1.get('description')}") ``` ```java GET /v1/services/messagingServices/{id}/versions -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = MessagingServices.getVersions("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); +EntityHistory history = client.messagingServices().getVersionList("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); + +for (Object version : history.getVersions()) { + System.out.println("Version: " + version); +} // Get a specific version -MessagingService v1 = MessagingServices.getSpecificVersion( - "469ef25e-9bdf-4d5f-8553-eb0ce8581f30", - "0.1" -); +MessagingService v1 = client.messagingServices().getVersion("469ef25e-9bdf-4d5f-8553-eb0ce8581f30", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/mlmodel-services/create.mdx b/v2.0.x/api-reference/data-assets/mlmodel-services/create.mdx index 096cf9df1..b01d04484 100644 --- a/v2.0.x/api-reference/data-assets/mlmodel-services/create.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodel-services/create.mdx @@ -16,7 +16,7 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Type of ML model service (e.g., `Mlflow`, `Sklearn`, `SageMaker`, `CustomMlModel`). + Type of ML model service, for example `Mlflow`, `Sklearn`, `SageMaker`, `CustomMlModel`. @@ -24,7 +24,7 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Service-specific connection configuration (e.g., `trackingUri`, `registryUri` for Mlflow). + Service-specific connection configuration, for example `trackingUri`, `registryUri` for Mlflow. @@ -46,7 +46,7 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,24 +68,33 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. ```python POST /v1/services/mlmodelServices -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.generated.schema.api.services.createMlModelService import CreateMlModelServiceRequest -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) request = CreateMlModelServiceRequest( @@ -103,20 +112,27 @@ request = CreateMlModelServiceRequest( } ) -service = MlModelServices.create(request) -print(f"Created: {service.fullyQualifiedName}") +service = metadata.create_or_update(request) +print(f"Created: {service.fullyQualifiedName.root}") ``` ```java POST /v1/services/mlmodelServices -import static org.openmetadata.sdk.fluent.MlModelServices.*; - -MlModelService service = MlModelServices.builder() - .name("mlflow_svc") - .serviceType("Mlflow") - .connection(mlflowConnection() - .trackingUri("http://localhost:8088") - .registryUri("http://localhost:8088")) - .create(); +import org.openmetadata.schema.api.services.CreateMlModelService; +import org.openmetadata.schema.api.services.CreateMlModelService.MlModelServiceType; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.schema.services.connections.mlmodel.MlflowConnection; +import org.openmetadata.schema.type.MlModelConnection; +import org.openmetadata.sdk.fluent.MlModelServices; + +CreateMlModelService request = new CreateMlModelService() + .withName("mlflow_svc") + .withServiceType(MlModelServiceType.Mlflow) + .withConnection(new MlModelConnection().withConfig( + new MlflowConnection() + .withTrackingUri("http://localhost:8088") + .withRegistryUri("http://localhost:8088"))); + +MlModelService service = MlModelServices.create(request); ``` ```bash POST /v1/services/mlmodelServices @@ -196,7 +212,7 @@ Returns the created ML model service object with all specified properties and sy - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker, CustomMlModel). + Type of ML model service, for example Mlflow, Sklearn, SageMaker, CustomMlModel. @@ -218,7 +234,7 @@ Returns the created ML model service object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -227,7 +243,7 @@ Returns the created ML model service object with all specified properties and sy - + Fully qualified name of the assigned domain. @@ -240,11 +256,11 @@ Returns the created ML model service object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/mlmodel-services/delete.mdx b/v2.0.x/api-reference/data-assets/mlmodel-services/delete.mdx index c2b42a870..43fcf5754 100644 --- a/v2.0.x/api-reference/data-assets/mlmodel-services/delete.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodel-services/delete.mdx @@ -28,7 +28,7 @@ Delete an ML model service by ID or fully qualified name. Supports soft delete ( Use `DELETE /v1/services/mlmodelServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the ML model service (e.g., `mlflow_svc`). + Fully qualified name of the ML model service, for example `mlflow_svc`. @@ -49,39 +49,56 @@ Use `PUT /v1/services/mlmodelServices/restore` to restore a soft-deleted ML mode ```python DELETE /v1/services/mlmodelServices/{id} -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Soft delete by ID -MlModelServices.delete("ca22d46e-81b9-4e48-85b5-0adc44980da9") +metadata.delete(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") # Hard delete -MlModelServices.delete( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", +metadata.delete( + entity=MlModelService, + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", hard_delete=True ) # Delete by name -MlModelServices.delete_by_name("mlflow_svc") +service = metadata.get_by_name(entity=MlModelService, fqn="mlflow_svc") +metadata.delete(entity=MlModelService, entity_id=service.id) # Delete by name with options -MlModelServices.delete_by_name( - "mlflow_svc", +service = metadata.get_by_name(entity=MlModelService, fqn="mlflow_svc") +metadata.delete( + entity=MlModelService, + entity_id=service.id, hard_delete=True, recursive=True ) # Restore a soft-deleted ML model service -MlModelServices.restore("ca22d46e-81b9-4e48-85b5-0adc44980da9") +metadata.restore(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") ``` ```java DELETE /v1/services/mlmodelServices/{id} -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.fluent.MlModelServices; + +// client is an initialized OpenMetadataClient. // Soft delete MlModelServices.delete("ca22d46e-81b9-4e48-85b5-0adc44980da9").execute(); @@ -91,11 +108,12 @@ MlModelServices.delete("ca22d46e-81b9-4e48-85b5-0adc44980da9") .hardDelete() .execute(); -// Delete by name -MlModelServices.deleteByName("mlflow_svc").execute(); +// Delete by name (look up the ID first) +MlModelService service = MlModelServices.retrieveByName("mlflow_svc"); +MlModelServices.delete(service.getId()).execute(); -// Restore -MlModelServices.restore("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +// Restore. The fluent class has no restore method, so use the client service. +client.mlModelServices().restore("ca22d46e-81b9-4e48-85b5-0adc44980da9"); ``` ```bash DELETE /v1/services/mlmodelServices/{id} diff --git a/v2.0.x/api-reference/data-assets/mlmodel-services/list.mdx b/v2.0.x/api-reference/data-assets/mlmodel-services/list.mdx index cc2b9b248..35f6a9674 100644 --- a/v2.0.x/api-reference/data-assets/mlmodel-services/list.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodel-services/list.mdx @@ -33,56 +33,64 @@ List all ML model services with optional filtering and pagination. ```python GET /v1/services/mlmodelServices -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List first page -services = MlModelServices.list(limit=50) -for svc in services.data: - print(f"{svc.fullyQualifiedName} ({svc.serviceType})") +services = metadata.list_entities(entity=MlModelService, limit=50) +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root} ({svc.serviceType.value})") # List all with auto-pagination -for svc in MlModelServices.list_all(): - print(f"{svc.fullyQualifiedName}") +for svc in metadata.list_all_entities(entity=MlModelService): + print(f"{svc.fullyQualifiedName.root}") # List with fields -services = MlModelServices.list( +services = metadata.list_entities( + entity=MlModelService, fields=["owners", "tags", "domains"], limit=50 ) -for svc in services.data: - print(f"{svc.fullyQualifiedName}") +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root}") if svc.owners: - print(f" Owners: {[o.name for o in svc.owners]}") + print(f" Owners: {[o.name for o in svc.owners.root]}") ``` ```java GET /v1/services/mlmodelServices -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = MlModelServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.mlModelServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (MlModelService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } -// List with fields -var result = MlModelServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); -} +// With fields +ListResponse withFields = client.mlModelServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/mlmodelServices @@ -160,7 +168,7 @@ Returns a paginated list of ML model service objects. By default, only basic fie - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker, CustomMlModel). + Type of ML model service, for example Mlflow, Sklearn, SageMaker, CustomMlModel. diff --git a/v2.0.x/api-reference/data-assets/mlmodel-services/retrieve.mdx b/v2.0.x/api-reference/data-assets/mlmodel-services/retrieve.mdx index cf91cf7ee..1bcee370b 100644 --- a/v2.0.x/api-reference/data-assets/mlmodel-services/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodel-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single ML model service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single ML model service by its unique ID or fully qualified name. Use `GET /v1/services/mlmodelServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the ML model service (e.g., `mlflow_svc`). + Fully qualified name of the ML model service, for example `mlflow_svc`. @@ -41,51 +41,64 @@ Use `GET /v1/services/mlmodelServices/name/{fqn}` to retrieve by fully qualified ```python GET /v1/services/mlmodelServices/{id} -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Get by ID -svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9") -print(f"{svc.fullyQualifiedName}: {svc.serviceType}") +svc = metadata.get_by_id(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") +print(f"{svc.fullyQualifiedName.root}: {svc.serviceType.value}") # Get by ID with fields -svc = MlModelServices.retrieve( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", +svc = metadata.get_by_id( + entity=MlModelService, + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", fields=["owners", "tags"] ) # Get by fully qualified name -svc = MlModelServices.retrieve_by_name("mlflow_svc") +svc = metadata.get_by_name(entity=MlModelService, fqn="mlflow_svc") # Get by name with fields -svc = MlModelServices.retrieve_by_name( - "mlflow_svc", +svc = metadata.get_by_name( + entity=MlModelService, + fqn="mlflow_svc", fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/services/mlmodelServices/{id} -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.fluent.MlModelServices; // Get by ID -var svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +MlModelService service = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); // Get by ID with fields -var svc = MlModelServices.retrieve( +MlModelService serviceWithFields = MlModelServices.retrieve( "ca22d46e-81b9-4e48-85b5-0adc44980da9", "owners,tags" ); // Get by fully qualified name -var svc = MlModelServices.retrieveByName("mlflow_svc"); +MlModelService serviceByName = MlModelServices.retrieveByName("mlflow_svc"); // Get by name with fields -var svc = MlModelServices.retrieveByName("mlflow_svc", "owners,tags,domains"); +MlModelService serviceByNameWithFields = MlModelServices.retrieveByName("mlflow_svc", "owners,tags,domains"); ``` ```bash GET /v1/services/mlmodelServices/{id} @@ -163,7 +176,7 @@ Returns an ML model service object with all requested fields populated. - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker, CustomMlModel). + Type of ML model service, for example Mlflow, Sklearn, SageMaker, CustomMlModel. diff --git a/v2.0.x/api-reference/data-assets/mlmodel-services/update.mdx b/v2.0.x/api-reference/data-assets/mlmodel-services/update.mdx index 9fa92a22e..f19c4f3d8 100644 --- a/v2.0.x/api-reference/data-assets/mlmodel-services/update.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodel-services/update.mdx @@ -20,7 +20,7 @@ Update an ML model service's properties using JSON Merge Patch. You can update b Use `PATCH /v1/services/mlmodelServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the ML model service (e.g., `mlflow_svc`). + Fully qualified name of the ML model service, for example `mlflow_svc`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,52 +68,58 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. ```python PATCH /v1/services/mlmodelServices/{id} -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Retrieve, modify, and update -svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9") -svc.description = "Updated: Production MLflow tracking server with model registry" -svc.connection = { - "config": { - "type": "Mlflow", - "trackingUri": "http://mlflow-prod:8088", - "registryUri": "http://mlflow-prod:8088", - "supportsMetadataExtraction": True - } -} -updated = MlModelServices.update(svc) - -print(f"Updated to version {updated.version}") +svc = metadata.get_by_id(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") +modified = svc.model_copy(deep=True) +modified.description = "Updated: Production MLflow tracking server with model registry" +modified.connection.config.trackingUri = "http://mlflow-prod:8088" +modified.connection.config.registryUri = "http://mlflow-prod:8088" +updated = metadata.patch(entity=MlModelService, source=svc, destination=modified) + +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/services/mlmodelServices/{id} -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.fluent.MlModelServices; // Retrieve, modify, and update -var svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); -svc.setDescription("Updated: Production MLflow tracking server with model registry"); -var updated = MlModelServices.update(svc); +MlModelService service = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +service.setDescription("Updated: Production MLflow tracking server with model registry"); +MlModelService updated = MlModelServices.update(service); ``` ```bash PATCH /v1/services/mlmodelServices/{id} diff --git a/v2.0.x/api-reference/data-assets/mlmodel-services/versions.mdx b/v2.0.x/api-reference/data-assets/mlmodel-services/versions.mdx index 7a37884e7..828c2be41 100644 --- a/v2.0.x/api-reference/data-assets/mlmodel-services/versions.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodel-services/versions.mdx @@ -24,47 +24,62 @@ Use `GET /v1/services/mlmodelServices/{id}/versions/{version}` to retrieve a spe - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/services/mlmodelServices/{id}/versions -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List all versions -versions = MlModelServices.get_versions("ca22d46e-81b9-4e48-85b5-0adc44980da9") -for v in versions: - print(f"Version {v.version}: {v.description}") +history = metadata.list_versions( + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", + entity=MlModelService +) +for v in history.versions: + svc_version = MlModelService.model_validate_json(v) + print(f"Version {svc_version.version.root}: {getattr(svc_version.description, 'root', svc_version.description)}") # Get a specific version -svc_v1 = MlModelServices.get_specific_version( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", - "0.1" +svc_v1 = metadata.get_entity_version( + entity=MlModelService, + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", + version="0.1" ) -print(f"Original description: {svc_v1.description}") +print(f"Original description: {getattr(svc_v1.description, 'root', svc_v1.description)}") ``` ```java GET /v1/services/mlmodelServices/{id}/versions -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = MlModelServices.getVersions("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +EntityHistory history = client.mlModelServices().getVersionList("ca22d46e-81b9-4e48-85b5-0adc44980da9"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = MlModelServices.getSpecificVersion( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", - 0.1 -); +MlModelService v1 = client.mlModelServices().getVersion("ca22d46e-81b9-4e48-85b5-0adc44980da9", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/mlmodels/create.mdx b/v2.0.x/api-reference/data-assets/mlmodels/create.mdx index a637fadc9..d7a44ac80 100644 --- a/v2.0.x/api-reference/data-assets/mlmodels/create.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodels/create.mdx @@ -16,11 +16,11 @@ Create a new ML model within an ML model service. - Fully qualified name of the parent MlModelService (e.g., `mlflow_svc`). + Fully qualified name of the parent MlModelService, for example `mlflow_svc`. - Algorithm used by the ML model (e.g., `KMeans`, `RandomForest`, `XGBoost`, `Neural Network`). + Algorithm used by the ML model, for example `KMeans`, `RandomForest`, `XGBoost`, `Neural Network`. @@ -40,7 +40,7 @@ Create a new ML model within an ML model service. - Data type of the feature (e.g., `numerical`, `categorical`). + Data type of the feature, for example `numerical`, `categorical`. @@ -56,7 +56,7 @@ Create a new ML model within an ML model service. - Reference to the source entity (e.g., a table or column). + Reference to the source entity, for example a table or column. @@ -108,7 +108,7 @@ Create a new ML model within an ML model service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -117,8 +117,8 @@ Create a new ML model within an ML model service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -130,11 +130,11 @@ Create a new ML model within an ML model service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -178,20 +178,28 @@ request = CreateMlModelRequest( ) model = MLModels.create(request) -print(f"Created: {model.fullyQualifiedName}") +print(f"Created: {model.fullyQualifiedName.root}") ``` ```java POST /v1/mlmodels -import static org.openmetadata.sdk.fluent.MlModels.*; - -// Create using builder pattern -var model = MlModels.builder() - .name("customer_segmentation") - .displayName("Customer Segmentation Model") - .service("mlflow_svc") - .algorithm("KMeans") - .description("Segments customers into groups based on purchasing behavior") - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateMlModel; +import org.openmetadata.schema.entity.data.MlModel; +import org.openmetadata.schema.type.MlFeature; +import org.openmetadata.schema.type.MlFeatureDataType; +import org.openmetadata.sdk.fluent.MlModels; + +CreateMlModel request = new CreateMlModel() + .withName("customer_segmentation") + .withDisplayName("Customer Segmentation Model") + .withService("mlflow_svc") + .withAlgorithm("KMeans") + .withDescription("Segments customers into groups based on purchasing behavior") + .withMlFeatures(List.of( + new MlFeature().withName("total_spend").withDataType(MlFeatureDataType.Numerical), + new MlFeature().withName("purchase_frequency").withDataType(MlFeatureDataType.Numerical))); + +MlModel model = MlModels.create(request); ``` ```bash POST /v1/mlmodels @@ -363,7 +371,7 @@ Returns the created ML model object with all specified properties and system-gen - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker). + Type of ML model service, for example Mlflow, Sklearn, SageMaker. @@ -375,7 +383,7 @@ Returns the created ML model object with all specified properties and system-gen - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -397,11 +405,11 @@ Returns the created ML model object with all specified properties and system-gen - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/mlmodels/delete.mdx b/v2.0.x/api-reference/data-assets/mlmodels/delete.mdx index 9acd600a0..93a26ebd3 100644 --- a/v2.0.x/api-reference/data-assets/mlmodels/delete.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodels/delete.mdx @@ -28,7 +28,7 @@ Delete an ML model by ID or fully qualified name. Supports soft delete (default) Use `DELETE /v1/mlmodels/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the ML model (e.g., `mlflow_svc.customer_segmentation`). + Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`. @@ -67,11 +67,13 @@ MLModels.delete( ) # Delete by name -MLModels.delete_by_name("mlflow_svc.customer_segmentation") +model = MLModels.retrieve_by_name("mlflow_svc.customer_segmentation") +MLModels.delete(model.id) # Delete by name with options -MLModels.delete_by_name( - "mlflow_svc.customer_segmentation", +model = MLModels.retrieve_by_name("mlflow_svc.customer_segmentation") +MLModels.delete( + model.id, hard_delete=True ) @@ -80,21 +82,23 @@ MLModels.restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") ``` ```java DELETE /v1/mlmodels/{id} -import static org.openmetadata.sdk.fluent.MlModels.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.MlModel; + +// client is an initialized OpenMetadataClient. // Soft delete -MlModels.delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2").execute(); +client.mlModels().delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); // Hard delete -MlModels.delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") - .hardDelete() - .execute(); +client.mlModels().delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", Map.of("hardDelete", "true")); -// Delete by name -MlModels.deleteByName("mlflow_svc.customer_segmentation").execute(); +// Delete by name (look up the ID first) +MlModel model = client.mlModels().getByName("mlflow_svc.customer_segmentation"); +client.mlModels().delete(model.getId()); // Restore -MlModels.restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +client.mlModels().restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); ``` ```bash DELETE /v1/mlmodels/{id} diff --git a/v2.0.x/api-reference/data-assets/mlmodels/followers-votes.mdx b/v2.0.x/api-reference/data-assets/mlmodels/followers-votes.mdx index a1d991972..f81404a73 100644 --- a/v2.0.x/api-reference/data-assets/mlmodels/followers-votes.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodels/followers-votes.mdx @@ -51,47 +51,56 @@ Manage followers and votes for ML model entities. ```python PUT /v1/mlmodels/{id}/followers -from metadata.sdk import configure +from metadata.sdk import client, configure from metadata.sdk.entities import MLModels configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client model_id = "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2" user_id = "user-uuid-here" # Add a follower model = MLModels.add_followers(model_id, [user_id]) -print(f"Followers: {len(model.followers)}") +print(f"Followers: {len(model.followers.root)}") # Remove a follower model = MLModels.remove_followers(model_id, [user_id]) # Add a vote -model = MLModels.add_vote(model_id, vote_type="votedUp") +rest.put(f"/mlmodels/{model_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -model = MLModels.remove_vote(model_id) +rest.put(f"/mlmodels/{model_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/mlmodels/{id}/followers -import static org.openmetadata.sdk.fluent.MlModels.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String modelId = "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -MlModels.addFollower(modelId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/mlmodels/" + modelId + "/followers", userId); // Remove a follower -MlModels.removeFollower(modelId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/mlmodels/" + modelId + "/followers/" + userId, null); // Add a vote -MlModels.vote(modelId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/mlmodels/" + modelId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -MlModels.vote(modelId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/mlmodels/" + modelId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/mlmodels/{id}/followers diff --git a/v2.0.x/api-reference/data-assets/mlmodels/list.mdx b/v2.0.x/api-reference/data-assets/mlmodels/list.mdx index 8c39be9a6..989135a51 100644 --- a/v2.0.x/api-reference/data-assets/mlmodels/list.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodels/list.mdx @@ -47,49 +47,52 @@ configure( # List first page models = MLModels.list(limit=50) -for m in models.data: - print(f"{m.fullyQualifiedName} ({m.algorithm})") +for m in models.entities: + print(f"{m.fullyQualifiedName.root} ({m.algorithm})") # List all with auto-pagination for m in MLModels.list_all(): - print(f"{m.fullyQualifiedName}") + print(f"{m.fullyQualifiedName.root}") # Filter by service models = MLModels.list( - service="mlflow_svc", + filters={"service": "mlflow_svc"}, fields=["owners", "tags", "domains"], limit=50 ) -for m in models.data: - print(f"{m.fullyQualifiedName}") +for m in models.entities: + print(f"{m.fullyQualifiedName.root}") if m.owners: - print(f" Owners: {[o.name for o in m.owners]}") + print(f" Owners: {[o.name for o in m.owners.root]}") if m.tags: - print(f" Tags: {[t.tagFQN for t in m.tags]}") + print(f" Tags: {[tag.tagFQN.root for tag in m.tags]}") ``` ```java GET /v1/mlmodels -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = MlModels.list() - .limit(50) - .execute(); +ListResponse firstPage = client.mlModels().list(new ListParams().setLimit(50)); -for (var m : result.getData()) { - System.out.println(m.getFullyQualifiedName()); +for (MlModel item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = MlModels.list() - .service("mlflow_svc") - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var m : result.getData()) { - System.out.println(m.getFullyQualifiedName()); +ListResponse filtered = client.mlModels().list( + new ListParams() + .setService("mlflow_svc") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (MlModel item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -186,7 +189,7 @@ Returns a paginated list of ML model objects. By default, only basic fields are - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker). + Type of ML model service, for example Mlflow, Sklearn, SageMaker. diff --git a/v2.0.x/api-reference/data-assets/mlmodels/retrieve.mdx b/v2.0.x/api-reference/data-assets/mlmodels/retrieve.mdx index 6bf39484c..19f1c2222 100644 --- a/v2.0.x/api-reference/data-assets/mlmodels/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodels/retrieve.mdx @@ -16,7 +16,7 @@ Get a single ML model by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single ML model by its unique ID or fully qualified name. Use `GET /v1/mlmodels/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the ML model (e.g., `mlflow_svc.customer_segmentation`). + Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`. @@ -51,7 +51,7 @@ configure( # Get by ID model = MLModels.retrieve("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") -print(f"{model.fullyQualifiedName}: {model.algorithm}") +print(f"{model.fullyQualifiedName.root}: {model.algorithm}") # Get by ID with fields model = MLModels.retrieve( @@ -70,22 +70,24 @@ model = MLModels.retrieve_by_name( ``` ```java GET /v1/mlmodels/{id} -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; + +// client is an initialized OpenMetadataClient. // Get by ID -var model = MlModels.retrieve("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +MlModel model = client.mlModels().get("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); // Get by ID with fields -var model = MlModels.retrieve( +MlModel modelWithFields = client.mlModels().get( "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", "owners,tags,followers,votes" ); // Get by fully qualified name -var model = MlModels.retrieveByName("mlflow_svc.customer_segmentation"); +MlModel modelByName = client.mlModels().getByName("mlflow_svc.customer_segmentation"); // Get by name with fields -var model = MlModels.retrieveByName( +MlModel modelByNameWithFields = client.mlModels().getByName( "mlflow_svc.customer_segmentation", "owners,tags,domains" ); @@ -210,7 +212,7 @@ Returns an ML model object with all requested fields populated. - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker). + Type of ML model service, for example Mlflow, Sklearn, SageMaker. diff --git a/v2.0.x/api-reference/data-assets/mlmodels/update.mdx b/v2.0.x/api-reference/data-assets/mlmodels/update.mdx index 8e4a00e1a..0371a8256 100644 --- a/v2.0.x/api-reference/data-assets/mlmodels/update.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodels/update.mdx @@ -20,7 +20,7 @@ Update an ML model's properties using JSON Merge Patch. You can update by ID or Use `PATCH /v1/mlmodels/name/{fqn}` to update by fully qualified name. - Fully qualified name of the ML model (e.g., `mlflow_svc.customer_segmentation`). + Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Data type of the feature (e.g., `numerical`, `categorical`). + Data type of the feature, for example `numerical`, `categorical`. @@ -80,7 +80,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -94,17 +94,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -130,16 +130,18 @@ model.mlHyperParameters = [ ] updated = MLModels.update(model) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/mlmodels/{id} -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var model = MlModels.retrieve("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +MlModel model = client.mlModels().get("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); model.setDescription("Updated: Customer segmentation using KMeans with 5 clusters"); -var updated = MlModels.update(model); +MlModel updated = client.mlModels().update(model.getId(), model); ``` ```bash PATCH /v1/mlmodels/{id} diff --git a/v2.0.x/api-reference/data-assets/mlmodels/versions.mdx b/v2.0.x/api-reference/data-assets/mlmodels/versions.mdx index 51758b323..c97d78f78 100644 --- a/v2.0.x/api-reference/data-assets/mlmodels/versions.mdx +++ b/v2.0.x/api-reference/data-assets/mlmodels/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/mlmodels/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/mlmodels/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import MLModels @@ -40,7 +42,8 @@ configure( # List all versions versions = MLModels.get_versions("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version model_v1 = MLModels.get_specific_version( @@ -51,21 +54,21 @@ print(f"Original algorithm: {model_v1.algorithm}") ``` ```java GET /v1/mlmodels/{id}/versions -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = MlModels.getVersions("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +EntityHistory history = client.mlModels().getVersionList("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = MlModels.getSpecificVersion( - "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", - 0.1 -); -System.out.println("Algorithm: " + v1.getAlgorithm()); +MlModel v1 = client.mlModels().getVersion("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", 0.1); +System.out.println("Description: " + v1.getDescription()); ``` ```bash GET /v1/mlmodels/{id}/versions diff --git a/v2.0.x/api-reference/data-assets/pipeline-services/create.mdx b/v2.0.x/api-reference/data-assets/pipeline-services/create.mdx index eca9f3d69..34be0380b 100644 --- a/v2.0.x/api-reference/data-assets/pipeline-services/create.mdx +++ b/v2.0.x/api-reference/data-assets/pipeline-services/create.mdx @@ -16,7 +16,7 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Type of pipeline service (e.g., `Airflow`, `GluePipeline`, `Airbyte`, `Dagster`, `Fivetran`, `DBTCloud`, `Nifi`, `DomoPipeline`, `CustomPipeline`, `Flink`, `KafkaConnect`, `SplineProducer`, `OpenLineage`). + Type of pipeline service, for example `Airflow`, `GluePipeline`, `Airbyte`, `Dagster`, `Fivetran`, `DBTCloud`, `Nifi`, `DomoPipeline`, `CustomPipeline`, `Flink`, `KafkaConnect`, `SplineProducer`, `OpenLineage`. @@ -24,7 +24,7 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Service-specific connection configuration (e.g., host, port, authentication for Airflow). + Service-specific connection configuration, for example host, port, authentication for Airflow. @@ -46,7 +46,7 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -113,14 +113,24 @@ print(f"Created: {service['fullyQualifiedName']}") ``` ```java POST /v1/services/pipelineServices -import static org.openmetadata.sdk.fluent.PipelineServices.*; - -PipelineService service = PipelineServices.builder() - .name("sample_airflow") - .serviceType("Airflow") - .connection(airflowConnection() - .hostPort("http://localhost:8080")) - .create(); +import java.net.URI; +import org.openmetadata.schema.api.services.CreatePipelineService; +import org.openmetadata.schema.api.services.CreatePipelineService.PipelineServiceType; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.schema.services.connections.pipeline.AirflowConnection; +import org.openmetadata.schema.services.connections.pipeline.BackendConnection; +import org.openmetadata.schema.type.PipelineConnection; +import org.openmetadata.sdk.fluent.PipelineServices; + +CreatePipelineService request = new CreatePipelineService() + .withName("sample_airflow") + .withServiceType(PipelineServiceType.Airflow) + .withConnection(new PipelineConnection().withConfig( + new AirflowConnection() + .withHostPort(URI.create("http://localhost:8080")) + .withConnection(new BackendConnection()))); + +PipelineService service = PipelineServices.create(request); ``` ```bash POST /v1/services/pipelineServices @@ -202,7 +212,7 @@ Returns the created pipeline service object with all specified properties and sy - Type of pipeline service (e.g., Airflow, Dagster, Fivetran). + Type of pipeline service, for example Airflow, Dagster, Fivetran. @@ -224,7 +234,7 @@ Returns the created pipeline service object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -233,7 +243,7 @@ Returns the created pipeline service object with all specified properties and sy - + Fully qualified name of the assigned domain. @@ -246,11 +256,11 @@ Returns the created pipeline service object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/pipeline-services/delete.mdx b/v2.0.x/api-reference/data-assets/pipeline-services/delete.mdx index 1aca19934..1ab3ef4b0 100644 --- a/v2.0.x/api-reference/data-assets/pipeline-services/delete.mdx +++ b/v2.0.x/api-reference/data-assets/pipeline-services/delete.mdx @@ -28,7 +28,7 @@ Delete a pipeline service by ID or fully qualified name. Supports soft delete (d Use `DELETE /v1/services/pipelineServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. @@ -81,7 +81,10 @@ requests.put( ``` ```java DELETE /v1/services/pipelineServices/{id} -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.fluent.PipelineServices; + +// client is an initialized OpenMetadataClient. // Soft delete PipelineServices.delete("daa58a49-df05-48a3-a417-45dfd12eacf5").execute(); @@ -92,11 +95,12 @@ PipelineServices.delete("daa58a49-df05-48a3-a417-45dfd12eacf5") .recursive() .execute(); -// Delete by name -PipelineServices.deleteByName("sample_airflow").execute(); +// Delete by name (look up the ID first) +PipelineService service = PipelineServices.retrieveByName("sample_airflow"); +PipelineServices.delete(service.getId()).execute(); -// Restore -PipelineServices.restore("daa58a49-df05-48a3-a417-45dfd12eacf5"); +// Restore. The fluent class has no restore method, so use the client service. +client.pipelineServices().restore("daa58a49-df05-48a3-a417-45dfd12eacf5"); ``` ```bash DELETE /v1/services/pipelineServices/{id} diff --git a/v2.0.x/api-reference/data-assets/pipeline-services/import-export.mdx b/v2.0.x/api-reference/data-assets/pipeline-services/import-export.mdx index a1e545dda..86c70b4c1 100644 --- a/v2.0.x/api-reference/data-assets/pipeline-services/import-export.mdx +++ b/v2.0.x/api-reference/data-assets/pipeline-services/import-export.mdx @@ -14,7 +14,7 @@ Export pipeline service metadata (pipelines, owners, tags) to CSV and import cha `GET /v1/services/pipelineServices/name/{fqn}/export` - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. ## Export Async @@ -79,38 +79,6 @@ response = requests.put( ) ``` -```java GET /v1/services/pipelineServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.PipelineServices; - -// Synchronous export -String csvData = PipelineServices.exportCsv("sample_airflow") - .execute(); - -// Async export -String jobId = PipelineServices.exportCsv("sample_airflow") - .async() - .execute(); - -// Synchronous import (dry run) -String result = PipelineServices.importCsv("sample_airflow") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = PipelineServices.importCsv("sample_airflow") - .withData(csvData) - .dryRun(false) - .execute(); - -// Async import -String jobId = PipelineServices.importCsv("sample_airflow") - .withData(csvData) - .dryRun(false) - .async() - .execute(); -``` - ```bash GET /v1/services/pipelineServices/name/{fqn}/export # Export to CSV curl "{base_url}/api/v1/services/pipelineServices/name/sample_airflow/export" \ diff --git a/v2.0.x/api-reference/data-assets/pipeline-services/list.mdx b/v2.0.x/api-reference/data-assets/pipeline-services/list.mdx index 3d20896a1..32ff85447 100644 --- a/v2.0.x/api-reference/data-assets/pipeline-services/list.mdx +++ b/v2.0.x/api-reference/data-assets/pipeline-services/list.mdx @@ -55,22 +55,23 @@ response = requests.get( ``` ```java GET /v1/services/pipelineServices -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = PipelineServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.pipelineServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (PipelineService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } // With fields -var result = PipelineServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); +ListResponse withFields = client.pipelineServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/pipelineServices @@ -140,7 +141,7 @@ Returns a paginated list of pipeline service objects. By default, only basic fie - Type of pipeline service (e.g., Airflow, Dagster, Fivetran). + Type of pipeline service, for example Airflow, Dagster, Fivetran. diff --git a/v2.0.x/api-reference/data-assets/pipeline-services/retrieve.mdx b/v2.0.x/api-reference/data-assets/pipeline-services/retrieve.mdx index 69e8c852f..00405a859 100644 --- a/v2.0.x/api-reference/data-assets/pipeline-services/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/pipeline-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single pipeline service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single pipeline service by its unique ID or fully qualified name. Use `GET /v1/services/pipelineServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. @@ -74,22 +74,23 @@ response = requests.get( ``` ```java GET /v1/services/pipelineServices/{id} -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.fluent.PipelineServices; // Get by ID -var svc = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); +PipelineService service = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); // Get by ID with fields -var svc = PipelineServices.retrieve( +PipelineService serviceWithFields = PipelineServices.retrieve( "daa58a49-df05-48a3-a417-45dfd12eacf5", "owners,tags,domains" ); // Get by fully qualified name -var svc = PipelineServices.retrieveByName("sample_airflow"); +PipelineService serviceByName = PipelineServices.retrieveByName("sample_airflow"); // Get by name with fields -var svc = PipelineServices.retrieveByName("sample_airflow", "owners,tags,domains"); +PipelineService serviceByNameWithFields = PipelineServices.retrieveByName("sample_airflow", "owners,tags,domains"); ``` ```bash GET /v1/services/pipelineServices/{id} @@ -159,7 +160,7 @@ Returns a pipeline service object with all requested fields populated. - Type of pipeline service (e.g., Airflow, Dagster, Fivetran). + Type of pipeline service, for example Airflow, Dagster, Fivetran. diff --git a/v2.0.x/api-reference/data-assets/pipeline-services/update.mdx b/v2.0.x/api-reference/data-assets/pipeline-services/update.mdx index e7440acf3..8a667bb88 100644 --- a/v2.0.x/api-reference/data-assets/pipeline-services/update.mdx +++ b/v2.0.x/api-reference/data-assets/pipeline-services/update.mdx @@ -20,7 +20,7 @@ Update a pipeline service's properties using JSON Merge Patch. You can update by Use `PATCH /v1/services/pipelineServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -104,12 +104,13 @@ print(f"Updated to version {updated['version']}") ``` ```java PATCH /v1/services/pipelineServices/{id} -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.fluent.PipelineServices; // Retrieve, modify, and update -var svc = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); -svc.setDescription("Updated Airflow production service"); -var updated = PipelineServices.update(svc); +PipelineService service = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); +service.setDescription("Updated Airflow production service"); +PipelineService updated = PipelineServices.update(service); ``` ```bash PATCH /v1/services/pipelineServices/{id} diff --git a/v2.0.x/api-reference/data-assets/pipeline-services/versions.mdx b/v2.0.x/api-reference/data-assets/pipeline-services/versions.mdx index 784d989f5..61dacd402 100644 --- a/v2.0.x/api-reference/data-assets/pipeline-services/versions.mdx +++ b/v2.0.x/api-reference/data-assets/pipeline-services/versions.mdx @@ -24,7 +24,7 @@ Use `GET /v1/services/pipelineServices/{id}/versions/{version}` to retrieve a sp - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. @@ -51,20 +51,20 @@ response = requests.get( ``` ```java GET /v1/services/pipelineServices/{id}/versions -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = PipelineServices.getVersions("daa58a49-df05-48a3-a417-45dfd12eacf5"); +EntityHistory history = client.pipelineServices().getVersionList("daa58a49-df05-48a3-a417-45dfd12eacf5"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = PipelineServices.getSpecificVersion( - "daa58a49-df05-48a3-a417-45dfd12eacf5", - 0.1 -); +PipelineService v1 = client.pipelineServices().getVersion("daa58a49-df05-48a3-a417-45dfd12eacf5", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/pipelines/create.mdx b/v2.0.x/api-reference/data-assets/pipelines/create.mdx index d321f385a..72bf64500 100644 --- a/v2.0.x/api-reference/data-assets/pipelines/create.mdx +++ b/v2.0.x/api-reference/data-assets/pipelines/create.mdx @@ -16,7 +16,7 @@ Create a new pipeline within a pipeline service. - Fully qualified name of the parent PipelineService (e.g., `sample_airflow`). + Fully qualified name of the parent PipelineService, for example `sample_airflow`. @@ -28,7 +28,7 @@ Create a new pipeline within a pipeline service. - URL to the pipeline definition in the source system (e.g., Airflow DAG URL). + URL to the pipeline definition in the source system, for example Airflow DAG URL. @@ -48,7 +48,7 @@ Create a new pipeline within a pipeline service. - Type of the task (e.g., `BatchTask`, `StreamTask`). + Type of the task, for example `BatchTask`, `StreamTask`. @@ -70,7 +70,7 @@ Create a new pipeline within a pipeline service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -79,8 +79,8 @@ Create a new pipeline within a pipeline service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -92,11 +92,11 @@ Create a new pipeline within a pipeline service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -144,19 +144,21 @@ request = CreatePipelineRequest( ) pipeline = Pipelines.create(request) -print(f"Created: {pipeline.fullyQualifiedName}") +print(f"Created: {pipeline.fullyQualifiedName.root}") ``` ```java POST /v1/pipelines -import static org.openmetadata.sdk.fluent.Pipelines.*; - -// Create using builder pattern -var pipeline = Pipelines.builder() - .name("dbt_analytics_customers") - .displayName("DBT Customer Analytics") - .service("sample_airflow") - .description("Analytics pipeline for customer data processing") - .create(); +import org.openmetadata.schema.api.data.CreatePipeline; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.sdk.fluent.Pipelines; + +CreatePipeline request = new CreatePipeline() + .withName("dbt_analytics_customers") + .withDisplayName("DBT Customer Analytics") + .withService("sample_airflow") + .withDescription("Analytics pipeline for customer data processing"); + +Pipeline pipeline = Pipelines.create(request); ``` ```bash POST /v1/pipelines @@ -300,7 +302,7 @@ Returns the created pipeline object with all specified properties and system-gen - Type of pipeline service (e.g., Airflow, Dagster, DBTCloud). + Type of pipeline service, for example Airflow, Dagster, DBTCloud. @@ -334,7 +336,7 @@ Returns the created pipeline object with all specified properties and system-gen - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -356,11 +358,11 @@ Returns the created pipeline object with all specified properties and system-gen - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/pipelines/delete.mdx b/v2.0.x/api-reference/data-assets/pipelines/delete.mdx index 3c4ef637c..a5c660bff 100644 --- a/v2.0.x/api-reference/data-assets/pipelines/delete.mdx +++ b/v2.0.x/api-reference/data-assets/pipelines/delete.mdx @@ -28,7 +28,7 @@ Delete a pipeline by ID or fully qualified name. Supports soft delete (default), Use `DELETE /v1/pipelines/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the pipeline (e.g., `sample_airflow.dbt_analytics_customers`). + Fully qualified name of the pipeline, for example `sample_airflow.dbt_analytics_customers`. @@ -67,11 +67,13 @@ Pipelines.delete( ) # Delete by name -Pipelines.delete_by_name("sample_airflow.dbt_analytics_customers") +pipeline = Pipelines.retrieve_by_name("sample_airflow.dbt_analytics_customers") +Pipelines.delete(pipeline.id) # Delete by name with options -Pipelines.delete_by_name( - "sample_airflow.dbt_analytics_customers", +pipeline = Pipelines.retrieve_by_name("sample_airflow.dbt_analytics_customers") +Pipelines.delete( + pipeline.id, hard_delete=True ) @@ -80,22 +82,23 @@ Pipelines.restore("538faa63-d204-46ff-aead-d158d0401cac") ``` ```java DELETE /v1/pipelines/{id} -import static org.openmetadata.sdk.fluent.Pipelines.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.Pipeline; + +// client is an initialized OpenMetadataClient. // Soft delete -Pipelines.delete("538faa63-d204-46ff-aead-d158d0401cac").execute(); +client.pipelines().delete("538faa63-d204-46ff-aead-d158d0401cac"); // Hard delete -Pipelines.delete("538faa63-d204-46ff-aead-d158d0401cac") - .hardDelete() - .execute(); +client.pipelines().delete("538faa63-d204-46ff-aead-d158d0401cac", Map.of("hardDelete", "true")); -// Delete by name -Pipelines.deleteByName("sample_airflow.dbt_analytics_customers") - .execute(); +// Delete by name (look up the ID first) +Pipeline pipeline = client.pipelines().getByName("sample_airflow.dbt_analytics_customers"); +client.pipelines().delete(pipeline.getId()); // Restore -Pipelines.restore("538faa63-d204-46ff-aead-d158d0401cac"); +client.pipelines().restore("538faa63-d204-46ff-aead-d158d0401cac"); ``` ```bash DELETE /v1/pipelines/{id} diff --git a/v2.0.x/api-reference/data-assets/pipelines/followers-votes.mdx b/v2.0.x/api-reference/data-assets/pipelines/followers-votes.mdx index 91de606b7..111fe82f2 100644 --- a/v2.0.x/api-reference/data-assets/pipelines/followers-votes.mdx +++ b/v2.0.x/api-reference/data-assets/pipelines/followers-votes.mdx @@ -51,47 +51,56 @@ Manage followers and votes for pipeline entities. ```python PUT /v1/pipelines/{id}/followers -from metadata.sdk import configure +from metadata.sdk import client, configure from metadata.sdk.entities import Pipelines configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client pipeline_id = "538faa63-d204-46ff-aead-d158d0401cac" user_id = "user-uuid-here" # Add a follower pipeline = Pipelines.add_followers(pipeline_id, [user_id]) -print(f"Followers: {len(pipeline.followers)}") +print(f"Followers: {len(pipeline.followers.root)}") # Remove a follower pipeline = Pipelines.remove_followers(pipeline_id, [user_id]) # Add a vote -pipeline = Pipelines.add_vote(pipeline_id, vote_type="votedUp") +rest.put(f"/pipelines/{pipeline_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -pipeline = Pipelines.remove_vote(pipeline_id) +rest.put(f"/pipelines/{pipeline_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/pipelines/{id}/followers -import static org.openmetadata.sdk.fluent.Pipelines.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String pipelineId = "538faa63-d204-46ff-aead-d158d0401cac"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -Pipelines.addFollower(pipelineId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/pipelines/" + pipelineId + "/followers", userId); // Remove a follower -Pipelines.removeFollower(pipelineId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/pipelines/" + pipelineId + "/followers/" + userId, null); // Add a vote -Pipelines.vote(pipelineId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/pipelines/" + pipelineId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -Pipelines.vote(pipelineId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/pipelines/" + pipelineId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/pipelines/{id}/followers diff --git a/v2.0.x/api-reference/data-assets/pipelines/list.mdx b/v2.0.x/api-reference/data-assets/pipelines/list.mdx index 173a1f872..a299d584d 100644 --- a/v2.0.x/api-reference/data-assets/pipelines/list.mdx +++ b/v2.0.x/api-reference/data-assets/pipelines/list.mdx @@ -47,49 +47,52 @@ configure( # List first page pipelines = Pipelines.list(limit=50) -for p in pipelines.data: - print(f"{p.fullyQualifiedName}") +for p in pipelines.entities: + print(f"{p.fullyQualifiedName.root}") # List all with auto-pagination for p in Pipelines.list_all(): - print(f"{p.fullyQualifiedName}") + print(f"{p.fullyQualifiedName.root}") # Filter by service pipelines = Pipelines.list( - service="sample_airflow", + filters={"service": "sample_airflow"}, fields=["owners", "tags", "tasks"], limit=50 ) -for p in pipelines.data: - print(f"{p.fullyQualifiedName}") +for p in pipelines.entities: + print(f"{p.fullyQualifiedName.root}") if p.owners: - print(f" Owners: {[o.name for o in p.owners]}") + print(f" Owners: {[o.name for o in p.owners.root]}") if p.tasks: - print(f" Tasks: {[t.name for t in p.tasks]}") + print(f" Tasks: {[task.name for task in p.tasks]}") ``` ```java GET /v1/pipelines -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = Pipelines.list() - .limit(50) - .execute(); +ListResponse firstPage = client.pipelines().list(new ListParams().setLimit(50)); -for (var p : result.getData()) { - System.out.println(p.getFullyQualifiedName()); +for (Pipeline item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = Pipelines.list() - .service("sample_airflow") - .fields("owners", "tags", "tasks") - .limit(50) - .execute(); - -for (var p : result.getData()) { - System.out.println(p.getFullyQualifiedName()); +ListResponse filtered = client.pipelines().list( + new ListParams() + .setService("sample_airflow") + .setFields("owners,tags,tasks") + .setLimit(50) +); + +for (Pipeline item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -181,7 +184,7 @@ Returns a paginated list of pipeline objects. By default, only basic fields are - Type of pipeline service (e.g., Airflow, Dagster, DBTCloud). + Type of pipeline service, for example Airflow, Dagster, DBTCloud. diff --git a/v2.0.x/api-reference/data-assets/pipelines/retrieve.mdx b/v2.0.x/api-reference/data-assets/pipelines/retrieve.mdx index 07a8956c3..15a7c5753 100644 --- a/v2.0.x/api-reference/data-assets/pipelines/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/pipelines/retrieve.mdx @@ -16,7 +16,7 @@ Get a single pipeline by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,tasks,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,tasks,sourceHash`. @@ -28,7 +28,7 @@ Get a single pipeline by its unique ID or fully qualified name. Use `GET /v1/pipelines/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the pipeline (e.g., `sample_airflow.dbt_analytics_customers`). + Fully qualified name of the pipeline, for example `sample_airflow.dbt_analytics_customers`. @@ -51,7 +51,7 @@ configure( # Get by ID pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac") -print(f"{pipeline.fullyQualifiedName}: {pipeline.description}") +print(f"{pipeline.fullyQualifiedName.root}: {getattr(pipeline.description, 'root', pipeline.description)}") # Get by ID with fields pipeline = Pipelines.retrieve( @@ -65,31 +65,31 @@ pipeline = Pipelines.retrieve_by_name("sample_airflow.dbt_analytics_customers") # Get by name with fields pipeline = Pipelines.retrieve_by_name( "sample_airflow.dbt_analytics_customers", - fields=["owners", "tags", "tasks", "domain"] + fields=["owners", "tags", "tasks", "domains"] ) ``` ```java GET /v1/pipelines/{id} -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; + +// client is an initialized OpenMetadataClient. // Get by ID -var pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac"); +Pipeline pipeline = client.pipelines().get("538faa63-d204-46ff-aead-d158d0401cac"); // Get by ID with fields -var pipeline = Pipelines.retrieve( +Pipeline pipelineWithFields = client.pipelines().get( "538faa63-d204-46ff-aead-d158d0401cac", "owners,tags,tasks" ); // Get by fully qualified name -var pipeline = Pipelines.retrieveByName( - "sample_airflow.dbt_analytics_customers" -); +Pipeline pipelineByName = client.pipelines().getByName("sample_airflow.dbt_analytics_customers"); // Get by name with fields -var pipeline = Pipelines.retrieveByName( +Pipeline pipelineByNameWithFields = client.pipelines().getByName( "sample_airflow.dbt_analytics_customers", - "owners,tags,tasks,domain" + "owners,tags,tasks,domains" ); ``` @@ -201,7 +201,7 @@ Returns a pipeline object with all requested fields populated. - Type of pipeline service (e.g., Airflow, Dagster, DBTCloud). + Type of pipeline service, for example Airflow, Dagster, DBTCloud. diff --git a/v2.0.x/api-reference/data-assets/pipelines/update.mdx b/v2.0.x/api-reference/data-assets/pipelines/update.mdx index 7e63e4e60..d28464480 100644 --- a/v2.0.x/api-reference/data-assets/pipelines/update.mdx +++ b/v2.0.x/api-reference/data-assets/pipelines/update.mdx @@ -20,7 +20,7 @@ Update a pipeline's properties using JSON Merge Patch. You can update by ID or b Use `PATCH /v1/pipelines/name/{fqn}` to update by fully qualified name. - Fully qualified name of the pipeline (e.g., `sample_airflow.dbt_analytics_customers`). + Fully qualified name of the pipeline, for example `sample_airflow.dbt_analytics_customers`. ## Body Parameters @@ -70,7 +70,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -84,17 +84,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -116,16 +116,18 @@ pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac") pipeline.description = "Updated: Analytics pipeline with incremental customer processing" updated = Pipelines.update(pipeline) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/pipelines/{id} -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac"); +Pipeline pipeline = client.pipelines().get("538faa63-d204-46ff-aead-d158d0401cac"); pipeline.setDescription("Updated: Analytics pipeline with incremental customer processing"); -var updated = Pipelines.update(pipeline); +Pipeline updated = client.pipelines().update(pipeline.getId(), pipeline); ``` ```bash PATCH /v1/pipelines/{id} diff --git a/v2.0.x/api-reference/data-assets/pipelines/versions.mdx b/v2.0.x/api-reference/data-assets/pipelines/versions.mdx index 91884d0d7..23ccd44a5 100644 --- a/v2.0.x/api-reference/data-assets/pipelines/versions.mdx +++ b/v2.0.x/api-reference/data-assets/pipelines/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/pipelines/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/pipelines/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Pipelines @@ -40,31 +42,32 @@ configure( # List all versions versions = Pipelines.get_versions("538faa63-d204-46ff-aead-d158d0401cac") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version pipeline_v1 = Pipelines.get_specific_version( "538faa63-d204-46ff-aead-d158d0401cac", "0.1" ) -print(f"Original description: {pipeline_v1.description}") +print(f"Original description: {getattr(pipeline_v1.description, 'root', pipeline_v1.description)}") ``` ```java GET /v1/pipelines/{id}/versions -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Pipelines.getVersions("538faa63-d204-46ff-aead-d158d0401cac"); +EntityHistory history = client.pipelines().getVersionList("538faa63-d204-46ff-aead-d158d0401cac"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Pipelines.getSpecificVersion( - "538faa63-d204-46ff-aead-d158d0401cac", - 0.1 -); +Pipeline v1 = client.pipelines().getVersion("538faa63-d204-46ff-aead-d158d0401cac", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/search-indexes/create.mdx b/v2.0.x/api-reference/data-assets/search-indexes/create.mdx index 94f1064f7..e5e11eeed 100644 --- a/v2.0.x/api-reference/data-assets/search-indexes/create.mdx +++ b/v2.0.x/api-reference/data-assets/search-indexes/create.mdx @@ -16,7 +16,7 @@ Create a new search index within a search service. - Fully qualified name of the parent SearchService (e.g., `elasticsearch_sample`). + Fully qualified name of the parent SearchService, for example `elasticsearch_sample`. @@ -28,7 +28,7 @@ Create a new search index within a search service. - Data type of the field (e.g., `TEXT`, `KEYWORD`, `INT`, `OBJECT`). + Data type of the field, for example `TEXT`, `KEYWORD`, `INT`, `OBJECT`. @@ -58,7 +58,7 @@ Create a new search index within a search service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -67,8 +67,8 @@ Create a new search index within a search service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -80,11 +80,11 @@ Create a new search index within a search service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -116,19 +116,27 @@ request = CreateSearchIndexRequest( ) search_index = SearchIndexes.create(request) -print(f"Created: {search_index.fullyQualifiedName}") +print(f"Created: {search_index.fullyQualifiedName.root}") ``` ```java POST /v1/searchIndexes -import static org.openmetadata.sdk.fluent.SearchIndexes.*; - -// Create using builder pattern -var searchIndex = SearchIndexes.builder() - .name("table_search_index") - .displayName("TableSearchIndex") - .service("elasticsearch_sample") - .description("Search index for table entities") - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateSearchIndex; +import org.openmetadata.schema.entity.data.SearchIndex; +import org.openmetadata.schema.type.SearchIndexDataType; +import org.openmetadata.schema.type.SearchIndexField; +import org.openmetadata.sdk.fluent.SearchIndexes; + +CreateSearchIndex request = new CreateSearchIndex() + .withName("table_search_index") + .withDisplayName("TableSearchIndex") + .withService("elasticsearch_sample") + .withDescription("Search index for table entities") + .withFields(List.of( + new SearchIndexField().withName("name").withDataType(SearchIndexDataType.TEXT), + new SearchIndexField().withName("description").withDataType(SearchIndexDataType.TEXT))); + +SearchIndex searchIndex = SearchIndexes.create(request); ``` ```bash POST /v1/searchIndexes @@ -256,7 +264,7 @@ Returns the created search index object with all specified properties and system - Type of search service (e.g., ElasticSearch, OpenSearch). + Type of search service, for example ElasticSearch, OpenSearch. @@ -268,7 +276,7 @@ Returns the created search index object with all specified properties and system - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -290,11 +298,11 @@ Returns the created search index object with all specified properties and system - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/search-indexes/delete.mdx b/v2.0.x/api-reference/data-assets/search-indexes/delete.mdx index fbfc5c0a8..7ecbf9f86 100644 --- a/v2.0.x/api-reference/data-assets/search-indexes/delete.mdx +++ b/v2.0.x/api-reference/data-assets/search-indexes/delete.mdx @@ -28,7 +28,7 @@ Delete a search index by ID or fully qualified name. Supports soft delete (defau Use `DELETE /v1/searchIndexes/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the search index (e.g., `elasticsearch_sample.table_search_index`). + Fully qualified name of the search index, for example `elasticsearch_sample.table_search_index`. @@ -67,11 +67,13 @@ SearchIndexes.delete( ) # Delete by name -SearchIndexes.delete_by_name("elasticsearch_sample.table_search_index") +index = SearchIndexes.retrieve_by_name("elasticsearch_sample.table_search_index") +SearchIndexes.delete(index.id) # Delete by name with options -SearchIndexes.delete_by_name( - "elasticsearch_sample.table_search_index", +index = SearchIndexes.retrieve_by_name("elasticsearch_sample.table_search_index") +SearchIndexes.delete( + index.id, hard_delete=True ) @@ -80,22 +82,23 @@ SearchIndexes.restore("f5b0fa81-f241-4508-9219-dae31dcced18") ``` ```java DELETE /v1/searchIndexes/{id} -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.SearchIndex; + +// client is an initialized OpenMetadataClient. // Soft delete -SearchIndexes.delete("f5b0fa81-f241-4508-9219-dae31dcced18").execute(); +client.searchIndexes().delete("f5b0fa81-f241-4508-9219-dae31dcced18"); // Hard delete -SearchIndexes.delete("f5b0fa81-f241-4508-9219-dae31dcced18") - .hardDelete() - .execute(); +client.searchIndexes().delete("f5b0fa81-f241-4508-9219-dae31dcced18", Map.of("hardDelete", "true")); -// Delete by name -SearchIndexes.deleteByName("elasticsearch_sample.table_search_index") - .execute(); +// Delete by name (look up the ID first) +SearchIndex searchIndex = client.searchIndexes().getByName("elasticsearch_sample.table_search_index"); +client.searchIndexes().delete(searchIndex.getId()); // Restore -SearchIndexes.restore("f5b0fa81-f241-4508-9219-dae31dcced18"); +client.searchIndexes().restore("f5b0fa81-f241-4508-9219-dae31dcced18"); ``` ```bash DELETE /v1/searchIndexes/{id} diff --git a/v2.0.x/api-reference/data-assets/search-indexes/followers-votes.mdx b/v2.0.x/api-reference/data-assets/search-indexes/followers-votes.mdx index ecddf695b..155fe12de 100644 --- a/v2.0.x/api-reference/data-assets/search-indexes/followers-votes.mdx +++ b/v2.0.x/api-reference/data-assets/search-indexes/followers-votes.mdx @@ -51,47 +51,56 @@ Manage followers and votes for search index entities. ```python PUT /v1/searchIndexes/{id}/followers -from metadata.sdk import configure +from metadata.sdk import client, configure from metadata.sdk.entities import SearchIndexes configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client si_id = "f5b0fa81-f241-4508-9219-dae31dcced18" user_id = "user-uuid-here" # Add a follower si = SearchIndexes.add_followers(si_id, [user_id]) -print(f"Followers: {len(si.followers)}") +print(f"Followers: {len(si.followers.root)}") # Remove a follower si = SearchIndexes.remove_followers(si_id, [user_id]) # Add a vote -si = SearchIndexes.add_vote(si_id, vote_type="votedUp") +rest.put(f"/searchIndexes/{si_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -si = SearchIndexes.remove_vote(si_id) +rest.put(f"/searchIndexes/{si_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/searchIndexes/{id}/followers -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String siId = "f5b0fa81-f241-4508-9219-dae31dcced18"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -SearchIndexes.addFollower(siId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/searchIndexes/" + siId + "/followers", userId); // Remove a follower -SearchIndexes.removeFollower(siId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/searchIndexes/" + siId + "/followers/" + userId, null); // Add a vote -SearchIndexes.vote(siId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/searchIndexes/" + siId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -SearchIndexes.vote(siId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/searchIndexes/" + siId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/searchIndexes/{id}/followers diff --git a/v2.0.x/api-reference/data-assets/search-indexes/list.mdx b/v2.0.x/api-reference/data-assets/search-indexes/list.mdx index 091a72ac4..7da009e21 100644 --- a/v2.0.x/api-reference/data-assets/search-indexes/list.mdx +++ b/v2.0.x/api-reference/data-assets/search-indexes/list.mdx @@ -47,49 +47,52 @@ configure( # List first page indexes = SearchIndexes.list(limit=50) -for si in indexes.data: - print(f"{si.fullyQualifiedName}") +for si in indexes.entities: + print(f"{si.fullyQualifiedName.root}") # List all with auto-pagination for si in SearchIndexes.list_all(): - print(f"{si.fullyQualifiedName}") + print(f"{si.fullyQualifiedName.root}") # Filter by service indexes = SearchIndexes.list( - service="elasticsearch_sample", - fields=["owners", "tags", "domain"], + filters={"service": "elasticsearch_sample"}, + fields=["owners", "tags", "domains"], limit=50 ) -for si in indexes.data: - print(f"{si.fullyQualifiedName}") +for si in indexes.entities: + print(f"{si.fullyQualifiedName.root}") if si.owners: - print(f" Owners: {[o.name for o in si.owners]}") + print(f" Owners: {[o.name for o in si.owners.root]}") if si.tags: - print(f" Tags: {[t.tagFQN for t in si.tags]}") + print(f" Tags: {[tag.tagFQN.root for tag in si.tags]}") ``` ```java GET /v1/searchIndexes -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = SearchIndexes.list() - .limit(50) - .execute(); +ListResponse firstPage = client.searchIndexes().list(new ListParams().setLimit(50)); -for (var si : result.getData()) { - System.out.println(si.getFullyQualifiedName()); +for (SearchIndex item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = SearchIndexes.list() - .service("elasticsearch_sample") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var si : result.getData()) { - System.out.println(si.getFullyQualifiedName()); +ListResponse filtered = client.searchIndexes().list( + new ListParams() + .setService("elasticsearch_sample") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (SearchIndex item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -179,7 +182,7 @@ Returns a paginated list of search index objects. By default, only basic fields - Type of search service (e.g., ElasticSearch, OpenSearch). + Type of search service, for example ElasticSearch, OpenSearch. diff --git a/v2.0.x/api-reference/data-assets/search-indexes/retrieve.mdx b/v2.0.x/api-reference/data-assets/search-indexes/retrieve.mdx index 3e9115922..21218be93 100644 --- a/v2.0.x/api-reference/data-assets/search-indexes/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/search-indexes/retrieve.mdx @@ -16,7 +16,7 @@ Get a single search index by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single search index by its unique ID or fully qualified name. Use `GET /v1/searchIndexes/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the search index (e.g., `elasticsearch_sample.table_search_index`). + Fully qualified name of the search index, for example `elasticsearch_sample.table_search_index`. @@ -51,7 +51,7 @@ configure( # Get by ID si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18") -print(f"{si.fullyQualifiedName}: {si.description}") +print(f"{si.fullyQualifiedName.root}: {getattr(si.description, 'root', si.description)}") # Get by ID with fields si = SearchIndexes.retrieve( @@ -65,31 +65,31 @@ si = SearchIndexes.retrieve_by_name("elasticsearch_sample.table_search_index") # Get by name with fields si = SearchIndexes.retrieve_by_name( "elasticsearch_sample.table_search_index", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/searchIndexes/{id} -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; + +// client is an initialized OpenMetadataClient. // Get by ID -var si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18"); +SearchIndex searchIndex = client.searchIndexes().get("f5b0fa81-f241-4508-9219-dae31dcced18"); // Get by ID with fields -var si = SearchIndexes.retrieve( +SearchIndex searchIndexWithFields = client.searchIndexes().get( "f5b0fa81-f241-4508-9219-dae31dcced18", "owners,tags,fields" ); // Get by fully qualified name -var si = SearchIndexes.retrieveByName( - "elasticsearch_sample.table_search_index" -); +SearchIndex searchIndexByName = client.searchIndexes().getByName("elasticsearch_sample.table_search_index"); // Get by name with fields -var si = SearchIndexes.retrieveByName( +SearchIndex searchIndexByNameWithFields = client.searchIndexes().getByName( "elasticsearch_sample.table_search_index", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -220,7 +220,7 @@ Returns a search index object with all requested fields populated. - Type of search service (e.g., ElasticSearch, OpenSearch). + Type of search service, for example ElasticSearch, OpenSearch. diff --git a/v2.0.x/api-reference/data-assets/search-indexes/update.mdx b/v2.0.x/api-reference/data-assets/search-indexes/update.mdx index 14626c8fb..cc837b01f 100644 --- a/v2.0.x/api-reference/data-assets/search-indexes/update.mdx +++ b/v2.0.x/api-reference/data-assets/search-indexes/update.mdx @@ -20,7 +20,7 @@ Update a search index's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/searchIndexes/name/{fqn}` to update by fully qualified name. - Fully qualified name of the search index (e.g., `elasticsearch_sample.table_search_index`). + Fully qualified name of the search index, for example `elasticsearch_sample.table_search_index`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,17 +58,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -90,16 +90,18 @@ si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18") si.description = "Updated: Search index for table entities with enhanced mapping" updated = SearchIndexes.update(si) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/searchIndexes/{id} -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18"); -si.setDescription("Updated: Search index for table entities with enhanced mapping"); -var updated = SearchIndexes.update(si); +SearchIndex searchIndex = client.searchIndexes().get("f5b0fa81-f241-4508-9219-dae31dcced18"); +searchIndex.setDescription("Updated: Search index for table entities with enhanced mapping"); +SearchIndex updated = client.searchIndexes().update(searchIndex.getId(), searchIndex); ``` ```bash PATCH /v1/searchIndexes/{id} diff --git a/v2.0.x/api-reference/data-assets/search-indexes/versions.mdx b/v2.0.x/api-reference/data-assets/search-indexes/versions.mdx index 9e36a2bcc..f62acaace 100644 --- a/v2.0.x/api-reference/data-assets/search-indexes/versions.mdx +++ b/v2.0.x/api-reference/data-assets/search-indexes/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/searchIndexes/{id}/versions/{version}` to retrieve a specific versi - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/searchIndexes/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import SearchIndexes @@ -40,31 +42,32 @@ configure( # List all versions versions = SearchIndexes.get_versions("f5b0fa81-f241-4508-9219-dae31dcced18") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version si_v1 = SearchIndexes.get_specific_version( "f5b0fa81-f241-4508-9219-dae31dcced18", "0.1" ) -print(f"Original description: {si_v1.description}") +print(f"Original description: {getattr(si_v1.description, 'root', si_v1.description)}") ``` ```java GET /v1/searchIndexes/{id}/versions -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = SearchIndexes.getVersions("f5b0fa81-f241-4508-9219-dae31dcced18"); +EntityHistory history = client.searchIndexes().getVersionList("f5b0fa81-f241-4508-9219-dae31dcced18"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = SearchIndexes.getSpecificVersion( - "f5b0fa81-f241-4508-9219-dae31dcced18", - 0.1 -); +SearchIndex v1 = client.searchIndexes().getVersion("f5b0fa81-f241-4508-9219-dae31dcced18", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/storage-services/create.mdx b/v2.0.x/api-reference/data-assets/storage-services/create.mdx index 54fcd1fb8..5ae74b3fd 100644 --- a/v2.0.x/api-reference/data-assets/storage-services/create.mdx +++ b/v2.0.x/api-reference/data-assets/storage-services/create.mdx @@ -16,7 +16,7 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Type of storage service (e.g., `S3`, `GCS`, `ADLS`, `CustomStorage`). + Type of storage service, for example `S3`, `GCS`, `ADLS`, `CustomStorage`. @@ -24,7 +24,7 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Service-specific connection configuration (e.g., AWS credentials for S3, project ID for GCS). + Service-specific connection configuration, for example AWS credentials for S3, project ID for GCS. @@ -46,7 +46,7 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -107,20 +107,29 @@ request = CreateStorageServiceRequest( ) service = StorageServices.create(request) -print(f"Created: {service.fullyQualifiedName}") +print(f"Created: {service.fullyQualifiedName.root}") ``` ```java POST /v1/services/storageServices -import static org.openmetadata.sdk.fluent.StorageServices.*; - -StorageService service = StorageServices.builder() - .name("s3_datalake") - .serviceType("S3") - .connection(s3Connection() - .awsAccessKeyId("AKIA...") - .awsSecretAccessKey("***") - .awsRegion("us-east-1")) - .create(); +import org.openmetadata.schema.api.services.CreateStorageService; +import org.openmetadata.schema.api.services.CreateStorageService.StorageServiceType; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.schema.security.credentials.AWSCredentials; +import org.openmetadata.schema.services.connections.storage.S3Connection; +import org.openmetadata.schema.type.StorageConnection; +import org.openmetadata.sdk.fluent.StorageServices; + +CreateStorageService request = new CreateStorageService() + .withName("s3_datalake") + .withServiceType(StorageServiceType.S3) + .withConnection(new StorageConnection().withConfig( + new S3Connection().withAwsConfig( + new AWSCredentials() + .withAwsAccessKeyId("AKIA...") + .withAwsSecretAccessKey("***") + .withAwsRegion("us-east-1")))); + +StorageService service = StorageServices.create(request); ``` ```bash POST /v1/services/storageServices @@ -207,7 +216,7 @@ Returns the created storage service object with all specified properties and sys - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -229,7 +238,7 @@ Returns the created storage service object with all specified properties and sys - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -238,7 +247,7 @@ Returns the created storage service object with all specified properties and sys - + Fully qualified name of the assigned domain. @@ -251,11 +260,11 @@ Returns the created storage service object with all specified properties and sys - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/storage-services/delete.mdx b/v2.0.x/api-reference/data-assets/storage-services/delete.mdx index a0d07c59b..89cab6fac 100644 --- a/v2.0.x/api-reference/data-assets/storage-services/delete.mdx +++ b/v2.0.x/api-reference/data-assets/storage-services/delete.mdx @@ -28,7 +28,7 @@ Delete a storage service by ID or fully qualified name. Supports soft delete (de Use `DELETE /v1/services/storageServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the storage service (e.g., `s3_datalake`). + Fully qualified name of the storage service, for example `s3_datalake`. @@ -67,11 +67,11 @@ StorageServices.delete( ) # Delete by name -StorageServices.delete_by_name("s3_datalake") +StorageServices.delete(StorageServices.retrieve_by_name("s3_datalake").id) # Delete by name with options -StorageServices.delete_by_name( - "s3_datalake", +StorageServices.delete( + StorageServices.retrieve_by_name("s3_datalake").id, hard_delete=True, recursive=True ) @@ -81,7 +81,10 @@ StorageServices.restore("d1589e1d-2ab0-431c-a383-15e4be20a106") ``` ```java DELETE /v1/services/storageServices/{id} -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.fluent.StorageServices; + +// client is an initialized OpenMetadataClient. // Soft delete StorageServices.delete("d1589e1d-2ab0-431c-a383-15e4be20a106").execute(); @@ -91,11 +94,12 @@ StorageServices.delete("d1589e1d-2ab0-431c-a383-15e4be20a106") .hardDelete() .execute(); -// Delete by name -StorageServices.deleteByName("s3_datalake").execute(); +// Delete by name (look up the ID first) +StorageService service = StorageServices.retrieveByName("s3_datalake"); +StorageServices.delete(service.getId()).execute(); -// Restore -StorageServices.restore("d1589e1d-2ab0-431c-a383-15e4be20a106"); +// Restore. The fluent class has no restore method, so use the client service. +client.storageServices().restore("d1589e1d-2ab0-431c-a383-15e4be20a106"); ``` ```bash DELETE /v1/services/storageServices/{id} diff --git a/v2.0.x/api-reference/data-assets/storage-services/list.mdx b/v2.0.x/api-reference/data-assets/storage-services/list.mdx index 2d7378506..9a296fed8 100644 --- a/v2.0.x/api-reference/data-assets/storage-services/list.mdx +++ b/v2.0.x/api-reference/data-assets/storage-services/list.mdx @@ -43,12 +43,12 @@ configure( # List first page services = StorageServices.list(limit=50) -for svc in services.data: - print(f"{svc.fullyQualifiedName} ({svc.serviceType})") +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root} ({svc.serviceType})") # List all with auto-pagination for svc in StorageServices.list_all(): - print(f"{svc.fullyQualifiedName}") + print(f"{svc.fullyQualifiedName.root}") # List with fields services = StorageServices.list( @@ -56,33 +56,30 @@ services = StorageServices.list( limit=50 ) -for svc in services.data: - print(f"{svc.fullyQualifiedName}") +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root}") if svc.owners: - print(f" Owners: {[o.name for o in svc.owners]}") + print(f" Owners: {[o.name for o in svc.owners.root]}") ``` ```java GET /v1/services/storageServices -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = StorageServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.storageServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (StorageService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } -// List with fields -var result = StorageServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); -} +// With fields +ListResponse withFields = client.storageServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/storageServices @@ -165,7 +162,7 @@ Returns a paginated list of storage service objects. By default, only basic fiel - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. diff --git a/v2.0.x/api-reference/data-assets/storage-services/retrieve.mdx b/v2.0.x/api-reference/data-assets/storage-services/retrieve.mdx index 7ee640325..56392dc50 100644 --- a/v2.0.x/api-reference/data-assets/storage-services/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/storage-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single storage service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single storage service by its unique ID or fully qualified name. Use `GET /v1/services/storageServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the storage service (e.g., `s3_datalake`). + Fully qualified name of the storage service, for example `s3_datalake`. @@ -51,7 +51,7 @@ configure( # Get by ID svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106") -print(f"{svc.fullyQualifiedName}: {svc.serviceType}") +print(f"{svc.fullyQualifiedName.root}: {svc.serviceType}") # Get by ID with fields svc = StorageServices.retrieve( @@ -70,22 +70,23 @@ svc = StorageServices.retrieve_by_name( ``` ```java GET /v1/services/storageServices/{id} -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.fluent.StorageServices; // Get by ID -var svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); +StorageService service = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); // Get by ID with fields -var svc = StorageServices.retrieve( +StorageService serviceWithFields = StorageServices.retrieve( "d1589e1d-2ab0-431c-a383-15e4be20a106", "owners,tags" ); // Get by fully qualified name -var svc = StorageServices.retrieveByName("s3_datalake"); +StorageService serviceByName = StorageServices.retrieveByName("s3_datalake"); // Get by name with fields -var svc = StorageServices.retrieveByName("s3_datalake", "owners,tags,domains"); +StorageService serviceByNameWithFields = StorageServices.retrieveByName("s3_datalake", "owners,tags,domains"); ``` ```bash GET /v1/services/storageServices/{id} @@ -168,7 +169,7 @@ Returns a storage service object with all requested fields populated. - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. diff --git a/v2.0.x/api-reference/data-assets/storage-services/update.mdx b/v2.0.x/api-reference/data-assets/storage-services/update.mdx index 8c583953e..d724d7f54 100644 --- a/v2.0.x/api-reference/data-assets/storage-services/update.mdx +++ b/v2.0.x/api-reference/data-assets/storage-services/update.mdx @@ -20,7 +20,7 @@ Update a storage service's properties using JSON Merge Patch. You can update by Use `PATCH /v1/services/storageServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the storage service (e.g., `s3_datalake`). + Fully qualified name of the storage service, for example `s3_datalake`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -96,16 +96,17 @@ svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106") svc.description = "Updated: Production S3 data lake with new region configuration" updated = StorageServices.update(svc) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/services/storageServices/{id} -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.fluent.StorageServices; // Retrieve, modify, and update -var svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); -svc.setDescription("Updated: Production S3 data lake with new region configuration"); -var updated = StorageServices.update(svc); +StorageService service = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); +service.setDescription("Updated: Production S3 data lake with new region configuration"); +StorageService updated = StorageServices.update(service); ``` ```bash PATCH /v1/services/storageServices/{id} diff --git a/v2.0.x/api-reference/data-assets/storage-services/versions.mdx b/v2.0.x/api-reference/data-assets/storage-services/versions.mdx index 9863d95dd..acca64ece 100644 --- a/v2.0.x/api-reference/data-assets/storage-services/versions.mdx +++ b/v2.0.x/api-reference/data-assets/storage-services/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/services/storageServices/{id}/versions/{version}` to retrieve a spe - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/services/storageServices/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import StorageServices @@ -40,31 +42,32 @@ configure( # List all versions versions = StorageServices.get_versions("d1589e1d-2ab0-431c-a383-15e4be20a106") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version svc_v1 = StorageServices.get_specific_version( "d1589e1d-2ab0-431c-a383-15e4be20a106", "0.1" ) -print(f"Original description: {svc_v1.description}") +print(f"Original description: {getattr(svc_v1.description, 'root', svc_v1.description)}") ``` ```java GET /v1/services/storageServices/{id}/versions -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = StorageServices.getVersions("d1589e1d-2ab0-431c-a383-15e4be20a106"); +EntityHistory history = client.storageServices().getVersionList("d1589e1d-2ab0-431c-a383-15e4be20a106"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = StorageServices.getSpecificVersion( - "d1589e1d-2ab0-431c-a383-15e4be20a106", - 0.1 -); +StorageService v1 = client.storageServices().getVersion("d1589e1d-2ab0-431c-a383-15e4be20a106", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/stored-procedures/create.mdx b/v2.0.x/api-reference/data-assets/stored-procedures/create.mdx index 9823729c4..bd0477ff2 100644 --- a/v2.0.x/api-reference/data-assets/stored-procedures/create.mdx +++ b/v2.0.x/api-reference/data-assets/stored-procedures/create.mdx @@ -16,7 +16,7 @@ Create a new stored procedure within a database schema. - Fully qualified name of the parent DatabaseSchema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the parent DatabaseSchema, for example `snowflake_prod.analytics.public`. @@ -28,7 +28,7 @@ Create a new stored procedure within a database schema. - Programming language of the code (e.g., `SQL`, `JavaScript`, `Python`). + Programming language of the code, for example `SQL`, `JavaScript`, `Python`. @@ -50,7 +50,7 @@ Create a new stored procedure within a database schema. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -59,8 +59,8 @@ Create a new stored procedure within a database schema. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -72,11 +72,11 @@ Create a new stored procedure within a database schema. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -108,19 +108,27 @@ request = CreateStoredProcedureRequest( ) stored_procedure = StoredProcedures.create(request) -print(f"Created: {stored_procedure.fullyQualifiedName}") +print(f"Created: {stored_procedure.fullyQualifiedName.root}") ``` ```java POST /v1/storedProcedures -import static org.openmetadata.sdk.fluent.StoredProcedures.*; - -// Create using builder pattern -var storedProcedure = StoredProcedures.builder() - .name("usp_refresh_analytics") - .displayName("Refresh Analytics") - .databaseSchema("snowflake_prod.analytics.public") - .description("Refreshes materialized analytics views nightly") - .create(); +import org.openmetadata.schema.api.data.CreateStoredProcedure; +import org.openmetadata.schema.entity.data.StoredProcedure; +import org.openmetadata.schema.api.data.StoredProcedureCode; +import org.openmetadata.schema.type.StoredProcedureLanguage; + +// client is an initialized OpenMetadataClient. + +CreateStoredProcedure request = new CreateStoredProcedure() + .withName("usp_refresh_analytics") + .withDisplayName("Refresh Analytics") + .withDatabaseSchema("snowflake_prod.analytics.public") + .withDescription("Refreshes materialized analytics views nightly") + .withStoredProcedureCode(new StoredProcedureCode() + .withCode("CREATE OR REPLACE PROCEDURE usp_refresh_analytics() ...") + .withLanguage(StoredProcedureLanguage.SQL)); + +StoredProcedure storedProcedure = client.storedProcedures().create(request); ``` ```bash POST /v1/storedProcedures @@ -249,7 +257,7 @@ Returns the created stored procedure object with all specified properties and sy - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -261,7 +269,7 @@ Returns the created stored procedure object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -283,11 +291,11 @@ Returns the created stored procedure object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/stored-procedures/delete.mdx b/v2.0.x/api-reference/data-assets/stored-procedures/delete.mdx index 2826b70d1..e2bcf6ae7 100644 --- a/v2.0.x/api-reference/data-assets/stored-procedures/delete.mdx +++ b/v2.0.x/api-reference/data-assets/stored-procedures/delete.mdx @@ -28,7 +28,7 @@ Delete a stored procedure by ID or fully qualified name. Supports soft delete (d Use `DELETE /v1/storedProcedures/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the stored procedure (e.g., `snowflake_prod.analytics.public.usp_refresh_analytics`). + Fully qualified name of the stored procedure, for example `snowflake_prod.analytics.public.usp_refresh_analytics`. @@ -66,36 +66,40 @@ StoredProcedures.delete( hard_delete=True ) -# Delete by name -StoredProcedures.delete_by_name("snowflake_prod.analytics.public.usp_refresh_analytics") +# Delete by name (look up the ID first) +entity = StoredProcedures.retrieve_by_name("snowflake_prod.analytics.public.usp_refresh_analytics") +StoredProcedures.delete(entity.id) # Delete by name with options -StoredProcedures.delete_by_name( - "snowflake_prod.analytics.public.usp_refresh_analytics", - hard_delete=True -) +entity = StoredProcedures.retrieve_by_name("snowflake_prod.analytics.public.usp_refresh_analytics") +StoredProcedures.delete(entity.id, hard_delete=True) # Restore a soft-deleted stored procedure StoredProcedures.restore("770e8400-e29b-41d4-a716-446655440000") ``` ```java DELETE /v1/storedProcedures/{id} -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -StoredProcedures.delete("770e8400-e29b-41d4-a716-446655440000").execute(); +client.storedProcedures().delete("770e8400-e29b-41d4-a716-446655440000"); // Hard delete -StoredProcedures.delete("770e8400-e29b-41d4-a716-446655440000") - .hardDelete() - .execute(); +client.storedProcedures().delete("770e8400-e29b-41d4-a716-446655440000", Map.of("hardDelete", "true")); // Delete by name -StoredProcedures.deleteByName("snowflake_prod.analytics.public.usp_refresh_analytics") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/storedProcedures/name/snowflake_prod.analytics.public.usp_refresh_analytics", + null, + Void.class +); // Restore -StoredProcedures.restore("770e8400-e29b-41d4-a716-446655440000"); +client.storedProcedures().restore("770e8400-e29b-41d4-a716-446655440000"); ``` ```bash DELETE /v1/storedProcedures/{id} diff --git a/v2.0.x/api-reference/data-assets/stored-procedures/followers-votes.mdx b/v2.0.x/api-reference/data-assets/stored-procedures/followers-votes.mdx index 172f5849f..4376c0aad 100644 --- a/v2.0.x/api-reference/data-assets/stored-procedures/followers-votes.mdx +++ b/v2.0.x/api-reference/data-assets/stored-procedures/followers-votes.mdx @@ -51,7 +51,7 @@ Manage followers and votes for stored procedure entities. ```python PUT /v1/storedProcedures/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import StoredProcedures configure( @@ -59,39 +59,62 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + sp_id = "770e8400-e29b-41d4-a716-446655440000" user_id = "user-uuid-here" # Add a follower sp = StoredProcedures.add_followers(sp_id, [user_id]) -print(f"Followers: {len(sp.followers)}") +print(f"Followers: {len(sp.followers.root)}") # Remove a follower sp = StoredProcedures.remove_followers(sp_id, [user_id]) # Add a vote -sp = StoredProcedures.add_vote(sp_id, vote_type="votedUp") +rest.put(f"/storedProcedures/{sp_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -sp = StoredProcedures.remove_vote(sp_id) +rest.put(f"/storedProcedures/{sp_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/storedProcedures/{id}/followers -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String spId = "770e8400-e29b-41d4-a716-446655440000"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; // Add a follower -StoredProcedures.addFollower(spId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/storedProcedures/" + spId + "/followers", + UUID.fromString(userId) +); // Remove a follower -StoredProcedures.removeFollower(spId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/storedProcedures/" + spId + "/followers/" + userId, + null +); // Add a vote -StoredProcedures.vote(spId, "votedUp"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/storedProcedures/" + spId + "/vote", + Map.of("updatedVoteType", "votedUp") +); // Remove a vote -StoredProcedures.vote(spId, "unVoted"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/storedProcedures/" + spId + "/vote", + Map.of("updatedVoteType", "unVoted") +); ``` ```bash PUT /v1/storedProcedures/{id}/followers diff --git a/v2.0.x/api-reference/data-assets/stored-procedures/list.mdx b/v2.0.x/api-reference/data-assets/stored-procedures/list.mdx index 6ddfef431..60af92a49 100644 --- a/v2.0.x/api-reference/data-assets/stored-procedures/list.mdx +++ b/v2.0.x/api-reference/data-assets/stored-procedures/list.mdx @@ -51,48 +51,53 @@ configure( # List first page procedures = StoredProcedures.list(limit=50) -for sp in procedures.data: - print(f"{sp.fullyQualifiedName}") +for sp in procedures.entities: + print(f"{sp.fullyQualifiedName.root}") # List all with auto-pagination for sp in StoredProcedures.list_all(): - print(f"{sp.fullyQualifiedName}") + print(f"{sp.fullyQualifiedName.root}") # Filter by database schema procedures = StoredProcedures.list( - databaseSchema="snowflake_prod.analytics.public", - fields=["owners", "tags", "domain"], + filters={"databaseSchema": "snowflake_prod.analytics.public"}, + fields=["owners", "tags", "domains"], limit=50 ) -for sp in procedures.data: - print(f"{sp.fullyQualifiedName}") +for sp in procedures.entities: + print(f"{sp.fullyQualifiedName.root}") if sp.owners: - print(f" Owners: {[o.name for o in sp.owners]}") + print(f" Owners: {[o.name for o in sp.owners.root]}") if sp.tags: - print(f" Tags: {[t.tagFQN for t in sp.tags]}") + print(f" Tags: {[t.tagFQN.root for t in sp.tags]}") ``` ```java GET /v1/storedProcedures -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.StoredProcedure; + +// client is an initialized OpenMetadataClient. // List first page -var result = StoredProcedures.list() - .limit(50) - .execute(); +ListResponse firstPage = client.storedProcedures().list( + new ListParams().setLimit(50) +); -for (var sp : result.getData()) { +for (StoredProcedure sp : firstPage.getData()) { System.out.println(sp.getFullyQualifiedName()); } // Filter by database schema with fields -var result = StoredProcedures.list() - .databaseSchema("snowflake_prod.analytics.public") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var sp : result.getData()) { +ListResponse filtered = client.storedProcedures().list( + new ListParams() + .setDatabaseSchema("snowflake_prod.analytics.public") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (StoredProcedure sp : filtered.getData()) { System.out.println(sp.getFullyQualifiedName()); } ``` @@ -199,7 +204,7 @@ Returns a paginated list of stored procedure objects. By default, only basic fie - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.0.x/api-reference/data-assets/stored-procedures/retrieve.mdx b/v2.0.x/api-reference/data-assets/stored-procedures/retrieve.mdx index d4707331f..3a75248e9 100644 --- a/v2.0.x/api-reference/data-assets/stored-procedures/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/stored-procedures/retrieve.mdx @@ -16,7 +16,7 @@ Get a single stored procedure by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single stored procedure by its unique ID or fully qualified name. Use `GET /v1/storedProcedures/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the stored procedure (e.g., `snowflake_prod.analytics.public.usp_refresh_analytics`). + Fully qualified name of the stored procedure, for example `snowflake_prod.analytics.public.usp_refresh_analytics`. @@ -51,7 +51,7 @@ configure( # Get by ID sp = StoredProcedures.retrieve("770e8400-e29b-41d4-a716-446655440000") -print(f"{sp.fullyQualifiedName}: {sp.description}") +print(f"{sp.fullyQualifiedName.root}: {sp.name.root}") # Get by ID with fields sp = StoredProcedures.retrieve( @@ -65,31 +65,33 @@ sp = StoredProcedures.retrieve_by_name("snowflake_prod.analytics.public.usp_refr # Get by name with fields sp = StoredProcedures.retrieve_by_name( "snowflake_prod.analytics.public.usp_refresh_analytics", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/storedProcedures/{id} -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.schema.entity.data.StoredProcedure; + +// client is an initialized OpenMetadataClient. // Get by ID -var sp = StoredProcedures.retrieve("770e8400-e29b-41d4-a716-446655440000"); +StoredProcedure sp = client.storedProcedures().get("770e8400-e29b-41d4-a716-446655440000"); // Get by ID with fields -var sp = StoredProcedures.retrieve( +StoredProcedure spWithFields = client.storedProcedures().get( "770e8400-e29b-41d4-a716-446655440000", "owners,tags,storedProcedureCode" ); // Get by fully qualified name -var sp = StoredProcedures.retrieveByName( +StoredProcedure spByName = client.storedProcedures().getByName( "snowflake_prod.analytics.public.usp_refresh_analytics" ); // Get by name with fields -var sp = StoredProcedures.retrieveByName( +StoredProcedure spByNameWithFields = client.storedProcedures().getByName( "snowflake_prod.analytics.public.usp_refresh_analytics", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -223,7 +225,7 @@ Returns a stored procedure object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.0.x/api-reference/data-assets/stored-procedures/update.mdx b/v2.0.x/api-reference/data-assets/stored-procedures/update.mdx index 75a05d6e5..3335fb00a 100644 --- a/v2.0.x/api-reference/data-assets/stored-procedures/update.mdx +++ b/v2.0.x/api-reference/data-assets/stored-procedures/update.mdx @@ -20,7 +20,7 @@ Update a stored procedure's properties using JSON Merge Patch. You can update by Use `PATCH /v1/storedProcedures/name/{fqn}` to update by fully qualified name. - Fully qualified name of the stored procedure (e.g., `snowflake_prod.analytics.public.usp_refresh_analytics`). + Fully qualified name of the stored procedure, for example `snowflake_prod.analytics.public.usp_refresh_analytics`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Programming language of the code (e.g., `SQL`, `JavaScript`, `Python`). + Programming language of the code, for example `SQL`, `JavaScript`, `Python`. @@ -58,7 +58,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -72,17 +72,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -108,16 +108,18 @@ sp.storedProcedureCode = { } updated = StoredProcedures.update(sp) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/storedProcedures/{id} -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.schema.entity.data.StoredProcedure; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var sp = StoredProcedures.retrieve("770e8400-e29b-41d4-a716-446655440000"); +StoredProcedure sp = client.storedProcedures().get("770e8400-e29b-41d4-a716-446655440000"); sp.setDescription("Updated: Refreshes materialized analytics views with incremental logic"); -var updated = StoredProcedures.update(sp); +StoredProcedure updated = client.storedProcedures().update("770e8400-e29b-41d4-a716-446655440000", sp); ``` ```bash PATCH /v1/storedProcedures/{id} diff --git a/v2.0.x/api-reference/data-assets/stored-procedures/versions.mdx b/v2.0.x/api-reference/data-assets/stored-procedures/versions.mdx index 3630b6d61..7c2211c3d 100644 --- a/v2.0.x/api-reference/data-assets/stored-procedures/versions.mdx +++ b/v2.0.x/api-reference/data-assets/stored-procedures/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/storedProcedures/{id}/versions/{version}` to retrieve a specific ve - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/storedProcedures/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import StoredProcedures @@ -40,28 +42,30 @@ configure( # List all versions versions = StoredProcedures.get_versions("770e8400-e29b-41d4-a716-446655440000") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version sp_v1 = StoredProcedures.get_specific_version( "770e8400-e29b-41d4-a716-446655440000", "0.1" ) -print(f"Original description: {sp_v1.description}") +print(f"Original description: {sp_v1.description.root if sp_v1.description else None}") ``` ```java GET /v1/storedProcedures/{id}/versions -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.schema.entity.data.StoredProcedure; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = StoredProcedures.getVersions("770e8400-e29b-41d4-a716-446655440000"); +EntityHistory history = client.storedProcedures().getVersionList("770e8400-e29b-41d4-a716-446655440000"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = StoredProcedures.getSpecificVersion( +StoredProcedure v1 = client.storedProcedures().getVersion( "770e8400-e29b-41d4-a716-446655440000", 0.1 ); diff --git a/v2.0.x/api-reference/data-assets/tables/create.mdx b/v2.0.x/api-reference/data-assets/tables/create.mdx index 6f1b9e302..5c2bf4c12 100644 --- a/v2.0.x/api-reference/data-assets/tables/create.mdx +++ b/v2.0.x/api-reference/data-assets/tables/create.mdx @@ -16,7 +16,7 @@ Create a new table within a database schema. - Fully qualified name of the parent DatabaseSchema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the parent DatabaseSchema, for example `snowflake_prod.analytics.public`. @@ -28,7 +28,7 @@ Create a new table within a database schema. - Data type of the column (e.g., `INT`, `VARCHAR`, `TIMESTAMP`, `BOOLEAN`, `ARRAY`, `MAP`). + Data type of the column, for example `INT`, `VARCHAR`, `TIMESTAMP`, `BOOLEAN`, `ARRAY`, `MAP`. @@ -36,7 +36,7 @@ Create a new table within a database schema. - Length of the data type (e.g., `256` for `VARCHAR(256)`). + Length of the data type, for example `256` for `VARCHAR(256`). @@ -62,7 +62,7 @@ Create a new table within a database schema. - Data retention period in ISO 8601 duration format (e.g., `P365D`). + Data retention period in ISO 8601 duration format, for example `P365D`. @@ -74,7 +74,7 @@ Create a new table within a database schema. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -83,8 +83,8 @@ Create a new table within a database schema. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -96,11 +96,11 @@ Create a new table within a database schema. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -131,21 +131,23 @@ request = CreateTableRequest( ) table = Tables.create(request) -print(f"Created: {table.fullyQualifiedName}") +print(f"Created: {table.fullyQualifiedName.root}") ``` ```java POST /v1/tables -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.fluent.builders.ColumnBuilder; +import org.openmetadata.sdk.fluent.builders.TableBuilder; -Table table = Tables.builder() +Table table = new TableBuilder(client) .name("customers") - .databaseSchema("snowflake_prod.analytics.public") - .columns(List.of( - column("id", "INT").constraint("PRIMARY_KEY"), - column("name", "VARCHAR").dataLength(256), - column("email", "VARCHAR").dataLength(256), - column("created_at", "TIMESTAMP") - )) + .schemaFQN("snowflake_prod.analytics.public") + .columns( + ColumnBuilder.integer("id").primaryKey(), + ColumnBuilder.varchar("name", 256), + ColumnBuilder.varchar("email", 256), + ColumnBuilder.timestamp("created_at") + ) .create(); ``` @@ -265,7 +267,7 @@ Returns the created table object with all specified properties, system-generated - Type of table (e.g., `Regular`, `View`, `MaterializedView`). + Type of table, for example `Regular`, `View`, `MaterializedView`. @@ -303,7 +305,7 @@ Returns the created table object with all specified properties, system-generated - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.0.x/api-reference/data-assets/tables/custom-metrics.mdx b/v2.0.x/api-reference/data-assets/tables/custom-metrics.mdx index fa3bc2a23..36f8e912f 100644 --- a/v2.0.x/api-reference/data-assets/tables/custom-metrics.mdx +++ b/v2.0.x/api-reference/data-assets/tables/custom-metrics.mdx @@ -37,6 +37,8 @@ Define custom SQL-based metrics on a table or specific column. Custom metrics ar `DELETE /v1/tables/{id}/customMetric/{metricName}` +To delete a column-level metric, use `DELETE /v1/tables/{id}/customMetric/{columnName}/{metricName}`. + UUID of the table. @@ -47,57 +49,68 @@ Define custom SQL-based metrics on a table or specific column. Custom metrics ar ```python PUT /v1/tables/{id}/customMetric -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Tables +from metadata.generated.schema.api.tests.createCustomMetric import CreateCustomMetricRequest configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add a table-level custom metric -Tables.add_custom_metric(table_id, { - "name": "active_customer_ratio", - "description": "Ratio of active customers to total customers", - "expression": "SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}" -}) +Tables.add_custom_metric(table_id, CreateCustomMetricRequest( + name="active_customer_ratio", + description="Ratio of active customers to total customers", + expression="SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}" +)) # Add a column-level custom metric -Tables.add_custom_metric(table_id, { - "name": "email_domain_count", - "description": "Number of distinct email domains", - "columnName": "email", - "expression": "SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}" -}) - -# Delete a custom metric -Tables.delete_custom_metric(table_id, "active_customer_ratio") +Tables.add_custom_metric(table_id, CreateCustomMetricRequest( + name="email_domain_count", + description="Number of distinct email domains", + columnName="email", + expression="SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}" +)) + +# Delete a table-level custom metric +rest.delete(f"/tables/{table_id}/customMetric/active_customer_ratio") + +# Delete a column-level custom metric +rest.delete(f"/tables/{table_id}/customMetric/email/email_domain_count") ``` ```java PUT /v1/tables/{id}/customMetric -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.tests.CustomMetric; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Add a table-level custom metric -Tables.addCustomMetric(tableId, Map.of( - "name", "active_customer_ratio", - "description", "Ratio of active customers to total customers", - "expression", "SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}" -)); +CustomMetric tableMetric = new CustomMetric() + .withName("active_customer_ratio") + .withDescription("Ratio of active customers to total customers") + .withExpression("SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}"); +client.tables().updateCustomMetric(tableId, tableMetric); // Add a column-level custom metric -Tables.addCustomMetric(tableId, Map.of( - "name", "email_domain_count", - "description", "Number of distinct email domains", - "columnName", "email", - "expression", "SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}" -)); - -// Delete a custom metric -Tables.deleteCustomMetric(tableId, "active_customer_ratio"); +CustomMetric columnMetric = new CustomMetric() + .withName("email_domain_count") + .withDescription("Number of distinct email domains") + .withColumnName("email") + .withExpression("SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}"); +client.tables().updateCustomMetric(tableId, columnMetric); + +// Delete a table-level custom metric +client.tables().deleteCustomMetric(tableId, "active_customer_ratio"); + +// Delete a column-level custom metric +client.tables().deleteCustomMetric(tableId, "email/email_domain_count"); ``` ```bash PUT /v1/tables/{id}/customMetric diff --git a/v2.0.x/api-reference/data-assets/tables/delete.mdx b/v2.0.x/api-reference/data-assets/tables/delete.mdx index 7e1167cf9..73e2d1744 100644 --- a/v2.0.x/api-reference/data-assets/tables/delete.mdx +++ b/v2.0.x/api-reference/data-assets/tables/delete.mdx @@ -28,7 +28,7 @@ Delete a table by ID or fully qualified name. Supports soft delete (default), ha Use `DELETE /v1/tables/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. @@ -67,24 +67,24 @@ Tables.delete( hard_delete=True ) -# Delete by name -Tables.delete_by_name("snowflake_prod.analytics.public.customers") +# Delete by name (look up the ID first) +entity = Tables.retrieve_by_name("snowflake_prod.analytics.public.customers") +Tables.delete(entity.id) # Restore a soft-deleted table Tables.restore("a1b2c3d4-e5f6-7890-abcd-ef1234567890") ``` ```java DELETE /v1/tables/{id} -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. // Soft delete -Tables.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890").execute(); +client.tables().delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Hard delete with recursive -Tables.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890") - .recursive() - .hardDelete() - .execute(); +client.tables().delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890", Map.of("recursive", "true", "hardDelete", "true")); ``` ```bash DELETE /v1/tables/{id} diff --git a/v2.0.x/api-reference/data-assets/tables/followers-votes.mdx b/v2.0.x/api-reference/data-assets/tables/followers-votes.mdx index 3d87e3b44..bd7990e1e 100644 --- a/v2.0.x/api-reference/data-assets/tables/followers-votes.mdx +++ b/v2.0.x/api-reference/data-assets/tables/followers-votes.mdx @@ -51,7 +51,7 @@ Manage followers and votes for table entities. Followers receive notifications a ```python PUT /v1/tables/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Tables configure( @@ -59,39 +59,62 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" user_id = "user-uuid-here" # Add a follower table = Tables.add_followers(table_id, [user_id]) -print(f"Followers: {len(table.followers)}") +print(f"Followers: {len(table.followers.root)}") # Remove a follower table = Tables.remove_followers(table_id, [user_id]) # Add a vote -table = Tables.add_vote(table_id, vote_type="votedUp") +rest.put(f"/tables/{table_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -table = Tables.remove_vote(table_id) +rest.put(f"/tables/{table_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/tables/{id}/followers -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; // Add a follower -Tables.addFollower(tableId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/tables/" + tableId + "/followers", + UUID.fromString(userId) +); // Remove a follower -Tables.removeFollower(tableId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/tables/" + tableId + "/followers/" + userId, + null +); // Add a vote -Tables.vote(tableId, "votedUp"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/tables/" + tableId + "/vote", + Map.of("updatedVoteType", "votedUp") +); // Remove a vote -Tables.vote(tableId, "unVoted"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/tables/" + tableId + "/vote", + Map.of("updatedVoteType", "unVoted") +); ``` ```bash PUT /v1/tables/{id}/followers diff --git a/v2.0.x/api-reference/data-assets/tables/import-export.mdx b/v2.0.x/api-reference/data-assets/tables/import-export.mdx index e915553d3..a97622f8d 100644 --- a/v2.0.x/api-reference/data-assets/tables/import-export.mdx +++ b/v2.0.x/api-reference/data-assets/tables/import-export.mdx @@ -14,7 +14,7 @@ Export table metadata (columns, owners, tags, descriptions) to CSV and import ch `GET /v1/tables/name/{fqn}/export` - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. ## Export Async @@ -80,6 +80,8 @@ result = ( ```java GET /v1/tables/name/{fqn}/export import org.openmetadata.sdk.fluent.Tables; +Tables.setDefaultClient(client); + // Synchronous export String csvData = Tables.exportCsv("snowflake_prod.analytics.public.customers") .execute(); @@ -90,15 +92,14 @@ String jobId = Tables.exportCsv("snowflake_prod.analytics.public.customers") .execute(); // Synchronous import (dry run) -String result = Tables.importCsv("snowflake_prod.analytics.public.customers") +String dryRunResult = Tables.importCsv("snowflake_prod.analytics.public.customers") .withData(csvData) - .dryRun(true) + .dryRun() .execute(); // Apply import String result = Tables.importCsv("snowflake_prod.analytics.public.customers") .withData(csvData) - .dryRun(false) .execute(); ``` diff --git a/v2.0.x/api-reference/data-assets/tables/list.mdx b/v2.0.x/api-reference/data-assets/tables/list.mdx index 117acc2d0..0e200b910 100644 --- a/v2.0.x/api-reference/data-assets/tables/list.mdx +++ b/v2.0.x/api-reference/data-assets/tables/list.mdx @@ -56,25 +56,30 @@ configure( # List with pagination page = Tables.list(limit=50, fields=["columns", "owners", "tags"]) for t in page.entities: - print(f"{t.fullyQualifiedName} ({len(t.columns or [])} columns)") + print(f"{t.fullyQualifiedName.root} ({len(t.columns or [])} columns)") # List all with auto-pagination all_tables = Tables.list_all(batch_size=100) for table in all_tables: - print(f"{table.fullyQualifiedName}") + print(f"{table.fullyQualifiedName.root}") ``` ```java GET /v1/tables -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // Retrieve by ID -Table table = Tables.retrieve(tableId); +Table table = client.tables().get(tableId); // List tables -var result = Tables.list() - .fields("columns", "owners", "tags") - .limit(50) - .execute(); +ListResponse
result = client.tables().list( + new ListParams() + .setFields("columns,owners,tags") + .setLimit(50) +); for (Table t : result.getData()) { System.out.println(t.getFullyQualifiedName()); @@ -203,7 +208,7 @@ Returns a paginated list of table objects. By default, only basic fields are inc - Type of table (e.g., `Regular`, `View`, `MaterializedView`). + Type of table, for example `Regular`, `View`, `MaterializedView`. diff --git a/v2.0.x/api-reference/data-assets/tables/observability.mdx b/v2.0.x/api-reference/data-assets/tables/observability.mdx index 6ea18c6db..3c6545813 100644 --- a/v2.0.x/api-reference/data-assets/tables/observability.mdx +++ b/v2.0.x/api-reference/data-assets/tables/observability.mdx @@ -25,69 +25,90 @@ Manage pipeline observability data for a table. This tracks which pipelines prod UUID of the table. - - Name of the pipeline. +The request body is a list. Each item describes one pipeline: + + + Reference to the pipeline. Include its `id` (UUID), `type` (`pipeline`), and `fullyQualifiedName`. - - Fully qualified name of the pipeline. + + Type of the pipeline service, such as `Airflow`. - - Status of the last pipeline run: `Successful`, `Failed`, `Pending`, `Aborted`. + + Schedule of the pipeline, as a cron expression. - + Unix timestamp (milliseconds) of the last pipeline run. - - Unix timestamp (milliseconds) of the next scheduled run. + + Status of the last pipeline run: `Successful`, `Failed`, `Pending`, `Skipped`. + + + + Average run time of the pipeline. ```python GET /v1/tables/{id}/pipelineObservability -from metadata.sdk import configure -from metadata.sdk.entities import Tables +from metadata.sdk import configure, client +from metadata.sdk.entities import Pipelines configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" +rest = client().ometa.client -# Get pipeline observability -observability = Tables.get_pipeline_observability(table_id) -for pipeline in observability: - print(f"{pipeline['pipelineName']}: {pipeline['lastRunStatus']}") +table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add pipeline observability -Tables.add_pipeline_observability(table_id, { - "pipelineName": "customer_etl", - "pipelineFQN": "airflow_prod.customer_etl", - "lastRunStatus": "Successful", - "lastRunTimestamp": 1706745600000, - "nextRunTimestamp": 1706832000000 -}) +pipeline = Pipelines.retrieve_by_name("airflow_prod.customer_etl") +rest.put(f"/tables/{table_id}/pipelineObservability", json=[{ + "pipeline": { + "id": str(pipeline.id.root), + "type": "pipeline", + "fullyQualifiedName": "airflow_prod.customer_etl" + }, + "serviceType": "Airflow", + "scheduleInterval": "0 0 * * *", + "lastRunTime": 1706745600000, + "lastRunStatus": "Successful" +}]) + +# Get pipeline observability +observability = rest.get(f"/tables/{table_id}/pipelineObservability") +for item in observability: + print(f"{item['pipeline']['fullyQualifiedName']}: {item['lastRunStatus']}") ``` ```java GET /v1/tables/{id}/pipelineObservability -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.List; +import org.openmetadata.schema.api.services.CreatePipelineService.PipelineServiceType; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.schema.type.PipelineObservability; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Get pipeline observability -var observability = Tables.getPipelineObservability(tableId); +List observability = client.tables().getPipelineObservability(tableId); // Add pipeline observability -Tables.addPipelineObservability(tableId, Map.of( - "pipelineName", "customer_etl", - "pipelineFQN", "airflow_prod.customer_etl", - "lastRunStatus", "Successful", - "lastRunTimestamp", 1706745600000L, - "nextRunTimestamp", 1706832000000L -)); +Pipeline pipeline = client.pipelines().getByName("airflow_prod.customer_etl"); + +PipelineObservability item = new PipelineObservability() + .withPipeline(pipeline.getEntityReference()) + .withServiceType(PipelineServiceType.Airflow) + .withScheduleInterval("0 0 * * *") + .withLastRunTime(1706745600000L) + .withLastRunStatus(PipelineObservability.LastRunStatus.SUCCESSFUL); + +client.tables().addPipelineObservability(tableId, List.of(item)); ``` ```bash GET /v1/tables/{id}/pipelineObservability @@ -99,25 +120,35 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/pipelineObse curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/pipelineObservability" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ - -d '{ - "pipelineName": "agent_metrics_etl", - "pipelineFQN": "airflow_prod.agent_metrics_etl", - "lastRunStatus": "Successful", - "lastRunTimestamp": 1769982651320, - "nextRunTimestamp": 1770069051320 - }' + -d '[{ + "pipeline": { + "id": "9a1d3c52-6f0b-4c1e-8a57-2b6f4e0d7c11", + "type": "pipeline", + "fullyQualifiedName": "airflow_prod.agent_metrics_etl" + }, + "serviceType": "Airflow", + "scheduleInterval": "0 0 * * *", + "lastRunTime": 1769982651320, + "lastRunStatus": "Successful" + }]' ``` ```json Response (Get Pipeline Observability) -{ - "pipelineName": "customer_etl", - "pipelineFQN": "airflow_prod.customer_etl", - "lastRunStatus": "Successful", - "lastRunTimestamp": 1706745600000, - "nextRunTimestamp": 1706832000000 -} +[ + { + "pipeline": { + "id": "9a1d3c52-6f0b-4c1e-8a57-2b6f4e0d7c11", + "type": "pipeline", + "fullyQualifiedName": "airflow_prod.customer_etl" + }, + "serviceType": "Airflow", + "scheduleInterval": "0 0 * * *", + "lastRunTime": 1706745600000, + "lastRunStatus": "Successful" + } +] ``` @@ -125,30 +156,34 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/pipel ## Returns -**Get** returns pipeline observability data associated with the table. +**Get** returns a list with one item for each pipeline linked to the table. -**Add** returns the updated pipeline observability data. +**Add** returns the updated table. ## Response - - Name of the pipeline. + + Reference to the pipeline, with its `id`, `type`, and `fullyQualifiedName`. - - Fully qualified name of the pipeline. + + Type of the pipeline service. - - Status of the last run. + + Schedule of the pipeline, as a cron expression. - + Unix timestamp of the last run in milliseconds. - - Unix timestamp of the next scheduled run in milliseconds. + + Status of the last run. + + + + Average run time of the pipeline. --- diff --git a/v2.0.x/api-reference/data-assets/tables/profiler.mdx b/v2.0.x/api-reference/data-assets/tables/profiler.mdx index 5a82e3315..360a5861d 100644 --- a/v2.0.x/api-reference/data-assets/tables/profiler.mdx +++ b/v2.0.x/api-reference/data-assets/tables/profiler.mdx @@ -2,7 +2,7 @@ title: Table Profiler description: Manage profiler configuration and retrieve profile data for tables sidebarTitle: Table Profiler -api: GET /v1/tables/{id}/profilerConfig +api: GET /v1/tables/{id}/tableProfilerConfig --- # Table Profiler @@ -11,7 +11,7 @@ Manage the profiler configuration for a table and retrieve profiling results inc ## Get Profiler Config -`GET /v1/tables/{id}/profilerConfig` +`GET /v1/tables/{id}/tableProfilerConfig` UUID of the table. @@ -19,7 +19,7 @@ Manage the profiler configuration for a table and retrieve profiling results inc ## Set Profiler Config -`PUT /v1/tables/{id}/profilerConfig` +`PUT /v1/tables/{id}/tableProfilerConfig` UUID of the table. @@ -61,7 +61,7 @@ Manage the profiler configuration for a table and retrieve profiling results inc ## Delete Profiler Config -`DELETE /v1/tables/{id}/profilerConfig` +`DELETE /v1/tables/{id}/tableProfilerConfig` UUID of the table. @@ -98,8 +98,8 @@ Returns system-level profiling results (DML operations, rows affected). -```python GET /v1/tables/{id}/profilerConfig -from metadata.sdk import configure +```python GET /v1/tables/{id}/tableProfilerConfig +from metadata.sdk import configure, client from metadata.sdk.entities import Tables configure( @@ -107,15 +107,18 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Get profiler config -config = Tables.get_profiler_config(table_id) -sample_config = config.get("profileSampleConfig", {}).get("config", {}) -print(f"Sample: {sample_config.get('profileSample')}%") +table = Tables.retrieve(table_id, fields=["tableProfilerConfig"]) +config = table.tableProfilerConfig +if config and config.profileSampleConfig: + print(f"Sample: {config.profileSampleConfig.config.profileSample}%") # Set profiler config - profile 50% of rows -Tables.set_profiler_config(table_id, { +rest.put(f"/tables/{table_id}/tableProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": {"profileSample": 50, "profileSampleType": "PERCENTAGE"} @@ -125,7 +128,7 @@ Tables.set_profiler_config(table_id, { }) # Set profiler config with specific column metrics -Tables.set_profiler_config(table_id, { +rest.put(f"/tables/{table_id}/tableProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": {"profileSample": 100, "profileSampleType": "PERCENTAGE"} @@ -137,38 +140,50 @@ Tables.set_profiler_config(table_id, { }) # Delete profiler config -Tables.delete_profiler_config(table_id) +rest.delete(f"/tables/{table_id}/tableProfilerConfig") ``` -```java GET /v1/tables/{id}/profilerConfig -import static org.openmetadata.sdk.fluent.Tables.*; +```java GET /v1/tables/{id}/tableProfilerConfig +import java.util.List; +import java.util.Map; +import org.openmetadata.schema.type.ProfileSampleConfig; +import org.openmetadata.schema.type.TableProfilerConfig; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Get profiler config -var config = Tables.getProfilerConfig(tableId); +TableProfilerConfig profilerConfig = client.tables() + .get(tableId, "tableProfilerConfig") + .getTableProfilerConfig(); // Set profiler config -Tables.setProfilerConfig(tableId, Map.of( - "profileSampleConfig", Map.of( - "sampleConfigType", "STATIC", - "config", Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE") - ), - "sampleDataCount", 200, - "excludeColumns", List.of("created_at") -)); +TableProfilerConfig newConfig = new TableProfilerConfig() + .withProfileSampleConfig(new ProfileSampleConfig() + .withSampleConfigType(ProfileSampleConfig.SampleConfigType.STATIC) + .withConfig(Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE"))) + .withSampleDataCount(200) + .withExcludeColumns(List.of("created_at")); +client.tables().updateProfilerConfig(tableId, newConfig); // Delete profiler config -Tables.deleteProfilerConfig(tableId); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/tables/" + tableId + "/tableProfilerConfig", + null, + Void.class +); ``` -```bash GET /v1/tables/{id}/profilerConfig +```bash GET /v1/tables/{id}/tableProfilerConfig # Get profiler config -curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profilerConfig" \ +curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/tableProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Set profiler config -curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profilerConfig" \ +curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/tableProfilerConfig" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -181,7 +196,7 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profi }' # Delete profiler config -curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profilerConfig" \ +curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/tableProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Get table profile @@ -201,12 +216,16 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/systemProfil ```json Response (Profiler Config) { - "profileSampleConfig": { - "sampleConfigType": "STATIC", - "config": {"profileSample": 50, "profileSampleType": "PERCENTAGE"} - }, - "sampleDataCount": 200, - "excludeColumns": ["created_at"] + "id": "455e3d9d-dbbf-455e-b3be-7191daa825f3", + "name": "agent_performance", + "tableProfilerConfig": { + "profileSampleConfig": { + "sampleConfigType": "STATIC", + "config": {"profileSample": 50, "profileSampleType": "PERCENTAGE"} + }, + "sampleDataCount": 200, + "excludeColumns": ["created_at"] + } } ``` @@ -215,11 +234,11 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/systemProfil ## Returns -**Get profiler config** returns the profiler configuration object. +**Get profiler config** returns the table. The configuration is in its `tableProfilerConfig` field. -**Set profiler config** returns the updated profiler configuration. +**Set profiler config** returns the updated table. -**Delete profiler config** returns no content (204). +**Delete profiler config** returns the updated table, without a profiler configuration. **Get table profile** returns table-level metrics (row count, size, etc.). @@ -229,6 +248,8 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/systemProfil ## Response (Profiler Config) +These fields are inside the table's `tableProfilerConfig` field. + How much data is profiled. Contains `sampleConfigType` (`STATIC` or `DYNAMIC`) and a `config` object holding the settings for that type. diff --git a/v2.0.x/api-reference/data-assets/tables/relationships.mdx b/v2.0.x/api-reference/data-assets/tables/relationships.mdx index 41d79793f..f68fc13c9 100644 --- a/v2.0.x/api-reference/data-assets/tables/relationships.mdx +++ b/v2.0.x/api-reference/data-assets/tables/relationships.mdx @@ -20,7 +20,7 @@ Record join information between this table and other tables. - Start date for the join period (ISO 8601 format). + Start date for the join period (ISO 8601 format). The period must fall within the past 30 days, ending today. In the examples, `{start_date}` stands for a date in this range, such as today's date. @@ -40,7 +40,7 @@ Record join information between this table and other tables. - FQN of the joined column (e.g., `snowflake_prod.analytics.public.orders.customer_id`). + FQN of the joined column, for example `snowflake_prod.analytics.public.orders.customer_id`. @@ -62,7 +62,7 @@ Set the data model (dbt or similar) associated with this table. - Type of data model: `DBT`, `LookML`. + Type of data model: `DBT` or `DDL`. @@ -74,7 +74,7 @@ Set the data model (dbt or similar) associated with this table. - Column descriptions and metadata from the data model. + Column descriptions and metadata from the data model. Each column needs a `name` and a `dataType`. ## Get Columns @@ -97,20 +97,23 @@ Retrieve column information with optional pagination. ```python PUT /v1/tables/{id}/joins -from metadata.sdk import configure -from metadata.sdk.entities import Tables +from datetime import date + +from metadata.sdk import configure, client configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add join information -Tables.add_joins(table_id, { - "startDate": "2024-01-01", - "dayCount": 30, +rest.put(f"/tables/{table_id}/joins", json={ + "startDate": date.today().isoformat(), + "dayCount": 1, "columnJoins": [ { "columnName": "id", @@ -125,47 +128,52 @@ Tables.add_joins(table_id, { }) # Set data model -Tables.set_data_model(table_id, { +rest.put(f"/tables/{table_id}/dataModel", json={ "modelType": "DBT", "description": "Customer dimension table built from raw events", "sql": "SELECT id, name, email, created_at FROM raw.customers WHERE active = true", "columns": [ - {"name": "id", "description": "Primary key from source"}, - {"name": "name", "description": "Customer full name"}, - {"name": "email", "description": "Verified email address"}, - {"name": "created_at", "description": "First seen timestamp"} + {"name": "id", "dataType": "INT", "description": "Primary key from source"}, + {"name": "name", "dataType": "VARCHAR", "description": "Customer full name"}, + {"name": "email", "dataType": "VARCHAR", "description": "Verified email address"}, + {"name": "created_at", "dataType": "TIMESTAMP", "description": "First seen timestamp"} ] }) ``` ```java PUT /v1/tables/{id}/joins -import static org.openmetadata.sdk.fluent.Tables.*; +import java.time.LocalDate; +import java.util.List; +import org.openmetadata.schema.type.ColumnJoin; +import org.openmetadata.schema.type.DataModel; +import org.openmetadata.schema.type.JoinedWith; +import org.openmetadata.schema.type.TableJoins; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Add join information -Tables.addJoins(tableId, Map.of( - "startDate", "2024-01-01", - "dayCount", 30, - "columnJoins", List.of( - Map.of( - "columnName", "id", - "joinedWith", List.of( - Map.of( - "fullyQualifiedName", "snowflake_prod.analytics.public.orders.customer_id", - "joinCount", 1542 - ) - ) - ) - ) -)); +TableJoins joins = new TableJoins() + .withStartDate(LocalDate.now().toString()) + .withDayCount(1) + .withColumnJoins(List.of( + new ColumnJoin() + .withColumnName("id") + .withJoinedWith(List.of( + new JoinedWith() + .withFullyQualifiedName("snowflake_prod.analytics.public.orders.customer_id") + .withJoinCount(1542) + )) + )); +client.tables().updateJoins(tableId, joins); // Set data model -Tables.setDataModel(tableId, Map.of( - "modelType", "DBT", - "description", "Customer dimension table built from raw events", - "sql", "SELECT id, name, email, created_at FROM raw.customers WHERE active = true" -)); +DataModel dataModel = new DataModel() + .withModelType(DataModel.ModelType.DBT) + .withDescription("Customer dimension table built from raw events") + .withSql("SELECT id, name, email, created_at FROM raw.customers WHERE active = true"); +client.tables().updateDataModel(tableId, dataModel); ``` ```bash PUT /v1/tables/{id}/joins @@ -174,8 +182,8 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/joins -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ - "startDate": "2024-01-01", - "dayCount": 30, + "startDate": "{start_date}", + "dayCount": 1, "columnJoins": [ { "columnName": "agent_id", @@ -208,8 +216,8 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/columns?limi ```json Response (Add Joins) { - "startDate": "2024-01-01", - "dayCount": 30, + "startDate": "{start_date}", + "dayCount": 1, "columnJoins": [ { "columnName": "agent_id", diff --git a/v2.0.x/api-reference/data-assets/tables/retrieve.mdx b/v2.0.x/api-reference/data-assets/tables/retrieve.mdx index 4ef5e0c6c..0ecb28395 100644 --- a/v2.0.x/api-reference/data-assets/tables/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/tables/retrieve.mdx @@ -28,7 +28,7 @@ Get a single table by its unique ID or fully qualified name. Use `GET /v1/tables/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. @@ -51,7 +51,7 @@ configure( # Get by ID table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890") -print(f"{table.fullyQualifiedName}: {table.description}") +print(f"{table.fullyQualifiedName.root}: {table.name.root}") # Get by ID with fields table = Tables.retrieve( @@ -70,13 +70,15 @@ table = Tables.retrieve_by_name( ``` ```java GET /v1/tables/{id} -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; + +// client is an initialized OpenMetadataClient. // Get by ID -Table table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +Table table = client.tables().get("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Get by fully qualified name -Table table = Tables.retrieveByName("snowflake_prod.analytics.public.customers"); +Table tableByName = client.tables().getByName("snowflake_prod.analytics.public.customers"); ``` ```bash GET /v1/tables/{id} diff --git a/v2.0.x/api-reference/data-assets/tables/sample-data.mdx b/v2.0.x/api-reference/data-assets/tables/sample-data.mdx index a41bc9edd..834f6d795 100644 --- a/v2.0.x/api-reference/data-assets/tables/sample-data.mdx +++ b/v2.0.x/api-reference/data-assets/tables/sample-data.mdx @@ -26,17 +26,7 @@ Manage sample data rows for a table. Sample data provides a preview of the table - Array of column references describing the sample data columns. - - - - Name of the column. - - - - Data type of the column. - - + Array of column names, in the same order as the values in each row. @@ -53,65 +43,68 @@ Manage sample data rows for a table. Sample data provides a preview of the table ```python GET /v1/tables/{id}/sampleData -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Tables +from metadata.generated.schema.entity.data.table import TableData configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" +rest = client().ometa.client -# Get sample data -sample = Tables.get_sample_data(table_id) -for row in sample.get("rows", []): - print(row) +table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add sample data -Tables.add_sample_data(table_id, { - "columns": [ - {"name": "id", "dataType": "INT"}, - {"name": "name", "dataType": "VARCHAR"}, - {"name": "email", "dataType": "VARCHAR"}, - {"name": "created_at", "dataType": "TIMESTAMP"} - ], - "rows": [ +Tables.add_sample_data(table_id, TableData( + columns=["id", "name", "email", "created_at"], + rows=[ [1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"], [2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"], [3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z"] ] -}) +)) + +# Get sample data +table = Tables.get_sample_data(table_id) +for row in table.sampleData.rows: + print(row) # Delete sample data -Tables.delete_sample_data(table_id) +rest.delete(f"/tables/{table_id}/sampleData") ``` ```java GET /v1/tables/{id}/sampleData -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.TableData; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Get sample data -var sample = Tables.getSampleData(tableId); +Table sample = client.tables().getSampleData(tableId); // Add sample data -Tables.addSampleData(tableId, Map.of( - "columns", List.of( - Map.of("name", "id", "dataType", "INT"), - Map.of("name", "name", "dataType", "VARCHAR"), - Map.of("name", "email", "dataType", "VARCHAR"), - Map.of("name", "created_at", "dataType", "TIMESTAMP") - ), - "rows", List.of( - List.of(1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"), - List.of(2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"), - List.of(3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z") - ) -)); +TableData sampleData = new TableData() + .withColumns(List.of("id", "name", "email", "created_at")) + .withRows(List.of( + List.of(1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"), + List.of(2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"), + List.of(3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z") + )); +client.tables().updateSampleData(tableId, sampleData); // Delete sample data -Tables.deleteSampleData(tableId); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/tables/" + tableId + "/sampleData", + null, + Void.class +); ``` ```bash GET /v1/tables/{id}/sampleData @@ -124,10 +117,7 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampl -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ - "columns": [ - {"name": "agent_id", "dataType": "VARCHAR"}, - {"name": "performance_score", "dataType": "DECIMAL"} - ], + "columns": ["agent_id", "performance_score"], "rows": [ ["AGT-001", 92.5], ["AGT-002", 87.3], @@ -144,15 +134,16 @@ curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sa ```json Response (Get Sample Data) { - "columns": [ - {"name": "agent_id", "dataType": "VARCHAR"}, - {"name": "performance_score", "dataType": "DECIMAL"} - ], - "rows": [ - ["AGT-001", 92.5], - ["AGT-002", 87.3], - ["AGT-003", 95.1] - ] + "id": "455e3d9d-dbbf-455e-b3be-7191daa825f3", + "name": "agent_performance", + "sampleData": { + "columns": ["agent_id", "performance_score"], + "rows": [ + ["AGT-001", 92.5], + ["AGT-002", 87.3], + ["AGT-003", 95.1] + ] + } } ``` @@ -161,26 +152,16 @@ curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sa ## Returns -**Get** returns the sample data object with columns and rows arrays. +**Get** returns the table. The sample data is in its `sampleData` field, with `columns` and `rows` arrays. -**Add** returns the updated sample data object. +**Add** returns the updated table. -**Delete** returns no content (204). +**Delete** returns the updated table, without sample data. ## Response - Array of column definitions for the sample data. - - - - Column name. - - - - Data type of the column. - - + Array of column names for the sample data. This field is inside `sampleData`. diff --git a/v2.0.x/api-reference/data-assets/tables/update.mdx b/v2.0.x/api-reference/data-assets/tables/update.mdx index a11af994f..10aa7ed85 100644 --- a/v2.0.x/api-reference/data-assets/tables/update.mdx +++ b/v2.0.x/api-reference/data-assets/tables/update.mdx @@ -20,7 +20,7 @@ Update a table's properties using JSON Merge Patch. You can update by ID or by f Use `PATCH /v1/tables/name/{fqn}` to update by fully qualified name. - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,11 +58,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -75,8 +75,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. Updated column definitions. Use this to update column descriptions, tags, or add new columns. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -98,16 +98,18 @@ table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890") table.description = "Updated customer master data table with PII fields" updated = Tables.update(table) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/tables/{id} -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -Table table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +Table table = client.tables().get("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); table.setDescription("Updated customer master data table with PII fields"); -Table updated = Tables.update(table); +Table updated = client.tables().update("a1b2c3d4-e5f6-7890-abcd-ef1234567890", table); ``` ```bash PATCH /v1/tables/{id} diff --git a/v2.0.x/api-reference/data-assets/tables/versions.mdx b/v2.0.x/api-reference/data-assets/tables/versions.mdx index e842e5181..69de38be5 100644 --- a/v2.0.x/api-reference/data-assets/tables/versions.mdx +++ b/v2.0.x/api-reference/data-assets/tables/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/tables/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/tables/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Tables @@ -40,26 +42,30 @@ configure( # List all versions versions = Tables.get_versions("a1b2c3d4-e5f6-7890-abcd-ef1234567890") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version table_v1 = Tables.get_specific_version( "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "0.1" ) -print(f"Original description: {table_v1.description}") +print(f"Original description: {table_v1.description.root if table_v1.description else None}") ``` ```java GET /v1/tables/{id}/versions -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = Tables.getVersions("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +EntityHistory versions = client.tables().getVersionList("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Get a specific version -Table v1 = Tables.getSpecificVersion( +Table v1 = client.tables().getVersion( "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "0.1" + 0.1 ); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-assets/topics/create.mdx b/v2.0.x/api-reference/data-assets/topics/create.mdx index 46dc41b30..42f31b955 100644 --- a/v2.0.x/api-reference/data-assets/topics/create.mdx +++ b/v2.0.x/api-reference/data-assets/topics/create.mdx @@ -16,7 +16,7 @@ Create a new topic within a messaging service. - Fully qualified name of the parent MessagingService (e.g., `sample_kafka`). + Fully qualified name of the parent MessagingService, for example `sample_kafka`. @@ -24,7 +24,7 @@ Create a new topic within a messaging service. - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`, `Other`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`, `Other`. @@ -38,7 +38,7 @@ Create a new topic within a messaging service. - Array of cleanup policies for the topic (e.g., `delete`, `compact`). + Array of cleanup policies for the topic, for example `delete`, `compact`. @@ -70,7 +70,7 @@ Create a new topic within a messaging service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -79,8 +79,8 @@ Create a new topic within a messaging service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -92,11 +92,11 @@ Create a new topic within a messaging service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -107,13 +107,22 @@ Create a new topic within a messaging service. ```python POST /v1/topics -from metadata.sdk import configure -from metadata.sdk.entities import Topics +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.generated.schema.api.data.createTopic import CreateTopicRequest -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) request = CreateTopicRequest( @@ -132,23 +141,28 @@ request = CreateTopicRequest( retentionSize=-1 ) -topic = Topics.create(request) -print(f"Created: {topic.fullyQualifiedName}") +topic = metadata.create_or_update(request) +print(f"Created: {topic.fullyQualifiedName.root}") ``` ```java POST /v1/topics -import static org.openmetadata.sdk.fluent.Topics.*; - -// Create using builder pattern -var topic = Topics.builder() - .name("address_book") - .displayName("Address Book") - .service("sample_kafka") - .description("All Protobuf record related events gets captured in this topic") - .partitions(1) - .cleanupPolicies(List.of("delete")) - .replicationFactor(1) - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateTopic; +import org.openmetadata.schema.entity.data.Topic; +import org.openmetadata.schema.type.topic.CleanupPolicy; + +// client is an initialized OpenMetadataClient. + +CreateTopic request = new CreateTopic() + .withName("address_book") + .withDisplayName("Address Book") + .withService("sample_kafka") + .withDescription("All Protobuf record related events gets captured in this topic") + .withPartitions(1) + .withCleanupPolicies(List.of(CleanupPolicy.DELETE)) + .withReplicationFactor(1); + +Topic topic = client.topics().create(request); ``` ```bash POST /v1/topics @@ -279,7 +293,7 @@ Returns the created topic object with all specified properties and system-genera - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`. @@ -313,7 +327,7 @@ Returns the created topic object with all specified properties and system-genera - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. @@ -325,7 +339,7 @@ Returns the created topic object with all specified properties and system-genera - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -347,11 +361,11 @@ Returns the created topic object with all specified properties and system-genera - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.0.x/api-reference/data-assets/topics/delete.mdx b/v2.0.x/api-reference/data-assets/topics/delete.mdx index c257242e7..ec7656a55 100644 --- a/v2.0.x/api-reference/data-assets/topics/delete.mdx +++ b/v2.0.x/api-reference/data-assets/topics/delete.mdx @@ -28,7 +28,7 @@ Delete a topic by ID or fully qualified name. Supports soft delete (default), ha Use `DELETE /v1/topics/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the topic (e.g., `sample_kafka.address_book`). + Fully qualified name of the topic, for example `sample_kafka.address_book`. @@ -49,53 +49,64 @@ Use `PUT /v1/topics/restore` to restore a soft-deleted topic. ```python DELETE /v1/topics/{id} -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Soft delete by ID -Topics.delete("0a021819-982e-4ee4-a5a2-4af30eaa3016") +metadata.delete(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") # Hard delete -Topics.delete( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", +metadata.delete( + entity=Topic, + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", hard_delete=True ) # Delete by name -Topics.delete_by_name("sample_kafka.address_book") +topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book") +metadata.delete(entity=Topic, entity_id=topic.id) # Delete by name with options -Topics.delete_by_name( - "sample_kafka.address_book", - hard_delete=True -) +topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book") +metadata.delete(entity=Topic, entity_id=topic.id, hard_delete=True) # Restore a soft-deleted topic -Topics.restore("0a021819-982e-4ee4-a5a2-4af30eaa3016") +metadata.restore(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") ``` ```java DELETE /v1/topics/{id} -import static org.openmetadata.sdk.fluent.Topics.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.Topic; + +// client is an initialized OpenMetadataClient. // Soft delete -Topics.delete("0a021819-982e-4ee4-a5a2-4af30eaa3016").execute(); +client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016"); // Hard delete -Topics.delete("0a021819-982e-4ee4-a5a2-4af30eaa3016") - .hardDelete() - .execute(); +client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016", Map.of("hardDelete", "true")); -// Delete by name -Topics.deleteByName("sample_kafka.address_book") - .execute(); +// Delete by name (look up the ID first) +Topic topic = client.topics().getByName("sample_kafka.address_book"); +client.topics().delete(topic.getId()); // Restore -Topics.restore("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +client.topics().restore("0a021819-982e-4ee4-a5a2-4af30eaa3016"); ``` ```bash DELETE /v1/topics/{id} diff --git a/v2.0.x/api-reference/data-assets/topics/followers-votes.mdx b/v2.0.x/api-reference/data-assets/topics/followers-votes.mdx index b9bec718f..331d96932 100644 --- a/v2.0.x/api-reference/data-assets/topics/followers-votes.mdx +++ b/v2.0.x/api-reference/data-assets/topics/followers-votes.mdx @@ -51,47 +51,66 @@ Manage followers and votes for topic entities. ```python PUT /v1/topics/{id}/followers -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) topic_id = "0a021819-982e-4ee4-a5a2-4af30eaa3016" user_id = "user-uuid-here" # Add a follower -topic = Topics.add_followers(topic_id, [user_id]) -print(f"Followers: {len(topic.followers)}") +metadata.client.put(f"/topics/{topic_id}/followers", json=user_id) +topic = metadata.get_by_id(entity=Topic, entity_id=topic_id, fields=["followers"]) +print(f"Followers: {len(topic.followers.root)}") # Remove a follower -topic = Topics.remove_followers(topic_id, [user_id]) +metadata.client.delete(f"/topics/{topic_id}/followers/{user_id}") # Add a vote -topic = Topics.add_vote(topic_id, vote_type="votedUp") +metadata.client.put(f"/topics/{topic_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -topic = Topics.remove_vote(topic_id) +metadata.client.put(f"/topics/{topic_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/topics/{id}/followers -import static org.openmetadata.sdk.fluent.Topics.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String topicId = "0a021819-982e-4ee4-a5a2-4af30eaa3016"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -Topics.addFollower(topicId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/topics/" + topicId + "/followers", userId); // Remove a follower -Topics.removeFollower(topicId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/topics/" + topicId + "/followers/" + userId, null); // Add a vote -Topics.vote(topicId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/topics/" + topicId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -Topics.vote(topicId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/topics/" + topicId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/topics/{id}/followers diff --git a/v2.0.x/api-reference/data-assets/topics/list.mdx b/v2.0.x/api-reference/data-assets/topics/list.mdx index d50439b00..e45df3cc7 100644 --- a/v2.0.x/api-reference/data-assets/topics/list.mdx +++ b/v2.0.x/api-reference/data-assets/topics/list.mdx @@ -37,59 +37,73 @@ List all topics with optional filtering and pagination. ```python GET /v1/topics -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List first page -topics = Topics.list(limit=50) -for t in topics.data: - print(f"{t.fullyQualifiedName}") +topics = metadata.list_entities(entity=Topic, limit=50) +for topic in topics.entities: + print(f"{topic.fullyQualifiedName.root}") # List all with auto-pagination -for t in Topics.list_all(): - print(f"{t.fullyQualifiedName}") +for topic in metadata.list_all_entities(entity=Topic): + print(f"{topic.fullyQualifiedName.root}") # Filter by service -topics = Topics.list( - service="sample_kafka", - fields=["owners", "tags", "domain"], +topics = metadata.list_entities( + entity=Topic, + fields=["owners", "tags", "domains"], + params={"service": "sample_kafka"}, limit=50 ) -for t in topics.data: - print(f"{t.fullyQualifiedName}") - if t.owners: - print(f" Owners: {[o.name for o in t.owners]}") - if t.tags: - print(f" Tags: {[t.tagFQN for t in t.tags]}") +for topic in topics.entities: + print(f"{topic.fullyQualifiedName.root}") + if topic.owners: + print(f" Owners: {[o.name for o in topic.owners.root]}") + if topic.tags: + print(f" Tags: {[tag.tagFQN.root for tag in topic.tags]}") ``` ```java GET /v1/topics -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = Topics.list() - .limit(50) - .execute(); +ListResponse firstPage = client.topics().list(new ListParams().setLimit(50)); -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +for (Topic item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = Topics.list() - .service("sample_kafka") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +ListResponse filtered = client.topics().list( + new ListParams() + .setService("sample_kafka") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (Topic item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -193,7 +207,7 @@ Returns a paginated list of topic objects. By default, only basic fields are inc - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v2.0.x/api-reference/data-assets/topics/retrieve.mdx b/v2.0.x/api-reference/data-assets/topics/retrieve.mdx index 8b5b9f6ba..f12f32e8d 100644 --- a/v2.0.x/api-reference/data-assets/topics/retrieve.mdx +++ b/v2.0.x/api-reference/data-assets/topics/retrieve.mdx @@ -16,7 +16,7 @@ Get a single topic by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single topic by its unique ID or fully qualified name. Use `GET /v1/topics/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the topic (e.g., `sample_kafka.address_book`). + Fully qualified name of the topic, for example `sample_kafka.address_book`. @@ -41,55 +41,67 @@ Use `GET /v1/topics/name/{fqn}` to retrieve by fully qualified name. ```python GET /v1/topics/{id} -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Get by ID -topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016") -print(f"{topic.fullyQualifiedName}: {topic.description}") +topic = metadata.get_by_id(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") +print(f"{topic.fullyQualifiedName.root}: {topic.description.root}") # Get by ID with fields -topic = Topics.retrieve( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", +topic = metadata.get_by_id( + entity=Topic, + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", fields=["owners", "tags", "messageSchema"] ) # Get by fully qualified name -topic = Topics.retrieve_by_name("sample_kafka.address_book") +topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book") # Get by name with fields -topic = Topics.retrieve_by_name( - "sample_kafka.address_book", - fields=["owners", "tags", "domain"] +topic = metadata.get_by_name( + entity=Topic, + fqn="sample_kafka.address_book", + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/topics/{id} -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; + +// client is an initialized OpenMetadataClient. // Get by ID -var topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +Topic topic = client.topics().get("0a021819-982e-4ee4-a5a2-4af30eaa3016"); // Get by ID with fields -var topic = Topics.retrieve( +Topic topicWithFields = client.topics().get( "0a021819-982e-4ee4-a5a2-4af30eaa3016", "owners,tags,messageSchema" ); // Get by fully qualified name -var topic = Topics.retrieveByName( - "sample_kafka.address_book" -); +Topic topicByName = client.topics().getByName("sample_kafka.address_book"); // Get by name with fields -var topic = Topics.retrieveByName( +Topic topicByNameWithFields = client.topics().getByName( "sample_kafka.address_book", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -219,7 +231,7 @@ Returns a topic object with all requested fields populated. - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`. @@ -233,7 +245,7 @@ Returns a topic object with all requested fields populated. - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v2.0.x/api-reference/data-assets/topics/update.mdx b/v2.0.x/api-reference/data-assets/topics/update.mdx index 2ef93788f..23e3ae18d 100644 --- a/v2.0.x/api-reference/data-assets/topics/update.mdx +++ b/v2.0.x/api-reference/data-assets/topics/update.mdx @@ -20,7 +20,7 @@ Update a topic's properties using JSON Merge Patch. You can update by ID or by f Use `PATCH /v1/topics/name/{fqn}` to update by fully qualified name. - Fully qualified name of the topic (e.g., `sample_kafka.address_book`). + Fully qualified name of the topic, for example `sample_kafka.address_book`. ## Body Parameters @@ -40,7 +40,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`, `Other`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`, `Other`. @@ -58,7 +58,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -72,17 +72,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -91,33 +91,47 @@ Send a JSON object with the fields to update. Only provided fields are changed. ```python PATCH /v1/topics/{id} -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic +from metadata.generated.schema.type.schema import SchemaType, Topic as TopicSchema + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Retrieve, modify, and update -topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016") -topic.description = "Updated: All Protobuf record events captured with enhanced schema" -topic.messageSchema = { - "schemaType": "Protobuf", - "schemaText": "syntax = \"proto3\";\npackage tutorial;\nmessage Person { ... }" -} -updated = Topics.update(topic) +topic = metadata.get_by_id(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") +modified = topic.model_copy(deep=True) +modified.description = "Updated: All Protobuf record events captured with enhanced schema" +modified.messageSchema = TopicSchema( + schemaType=SchemaType.Protobuf, + schemaText="syntax = \"proto3\";\npackage tutorial;\nmessage Person { ... }" +) +updated = metadata.patch(entity=Topic, source=topic, destination=modified) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/topics/{id} -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +Topic topic = client.topics().get("0a021819-982e-4ee4-a5a2-4af30eaa3016"); topic.setDescription("Updated: All Protobuf record events captured with enhanced schema"); -var updated = Topics.update(topic); +Topic updated = client.topics().update(topic.getId(), topic); ``` ```bash PATCH /v1/topics/{id} diff --git a/v2.0.x/api-reference/data-assets/topics/versions.mdx b/v2.0.x/api-reference/data-assets/topics/versions.mdx index c2fdf49fd..ad2bb1382 100644 --- a/v2.0.x/api-reference/data-assets/topics/versions.mdx +++ b/v2.0.x/api-reference/data-assets/topics/versions.mdx @@ -24,47 +24,62 @@ Use `GET /v1/topics/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/topics/{id}/versions -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List all versions -versions = Topics.get_versions("0a021819-982e-4ee4-a5a2-4af30eaa3016") -for v in versions: - print(f"Version {v.version}: {v.description}") +history = metadata.list_versions( + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", + entity=Topic +) +for v in history.versions: + topic_version = Topic.model_validate_json(v) + print(f"Version {topic_version.version.root}: {topic_version.description.root}") # Get a specific version -topic_v1 = Topics.get_specific_version( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", - "0.1" +topic_v1 = metadata.get_entity_version( + entity=Topic, + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", + version="0.1" ) -print(f"Original description: {topic_v1.description}") +print(f"Original description: {topic_v1.description.root}") ``` ```java GET /v1/topics/{id}/versions -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Topics.getVersions("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +EntityHistory history = client.topics().getVersionList("0a021819-982e-4ee4-a5a2-4af30eaa3016"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Topics.getSpecificVersion( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", - 0.1 -); +Topic v1 = client.topics().getVersion("0a021819-982e-4ee4-a5a2-4af30eaa3016", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/data-contracts/delete.mdx b/v2.0.x/api-reference/data-contracts/delete.mdx index e58a26fbe..5b5f8af11 100644 --- a/v2.0.x/api-reference/data-contracts/delete.mdx +++ b/v2.0.x/api-reference/data-contracts/delete.mdx @@ -67,7 +67,7 @@ curl -X DELETE "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def12345 -H "Authorization: Bearer {access_token}" # Delete by FQN -curl -X DELETE "{base_url}/api/v1/dataContracts/name/sales-orders-contract?hardDelete=true" \ +curl -X DELETE "{base_url}/api/v1/dataContracts/name/sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract?hardDelete=true" \ -H "Authorization: Bearer {access_token}" # Restore soft-deleted contract diff --git a/v2.0.x/api-reference/data-contracts/list.mdx b/v2.0.x/api-reference/data-contracts/list.mdx index 88c4f2b0b..af34ed326 100644 --- a/v2.0.x/api-reference/data-contracts/list.mdx +++ b/v2.0.x/api-reference/data-contracts/list.mdx @@ -49,13 +49,13 @@ configure( jwt_token="your-jwt-token" ) -# List all active contracts -contracts = DataContracts.list(params={"status": "Approved"}) -for c in contracts.data: - print(f"{c.fullyQualifiedName} ({c.entityStatus})") +# List approved contracts +contracts = DataContracts.list(filters={"status": "Approved"}) +for c in contracts.entities: + print(f"{c.fullyQualifiedName.root} ({c.entityStatus})") # List contracts for a specific entity -contracts = DataContracts.list(params={ +contracts = DataContracts.list(filters={ "entity": "a1b2c3d4-e5f6-7890-abcd-ef1234567890" }) ``` @@ -74,7 +74,7 @@ list().limit(20).fetch().forEach(contract -> { curl "{base_url}/api/v1/dataContracts?limit=10" \ -H "Authorization: Bearer {access_token}" -# List active contracts +# List approved contracts curl "{base_url}/api/v1/dataContracts?status=Approved&fields=owners" \ -H "Authorization: Bearer {access_token}" @@ -91,7 +91,7 @@ curl "{base_url}/api/v1/dataContracts?entity=a1b2c3d4-e5f6-7890-abcd-ef123456789 { "id": "f7a1b2c3-d4e5-6789-0abc-def123456789", "name": "sales-orders-contract", - "fullyQualifiedName": "sales-orders-contract", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "entityStatus": "Approved", "entity": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", diff --git a/v2.0.x/api-reference/data-contracts/odcs.mdx b/v2.0.x/api-reference/data-contracts/odcs.mdx index d00871bf8..e2e5aaf7f 100644 --- a/v2.0.x/api-reference/data-contracts/odcs.mdx +++ b/v2.0.x/api-reference/data-contracts/odcs.mdx @@ -63,16 +63,26 @@ yaml_str = DataContracts.export_odcs(contract_id).as_yaml().execute() print(yaml_str) # Export by FQN -odcs = DataContracts.export_odcs_by_name("sales-orders-contract").execute() +odcs = DataContracts.export_odcs_by_name("sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract").execute() ``` ```java Export ODCS -// Export using the REST client +import java.util.UUID; + +// client is an initialized OpenMetadataClient. +var contractId = UUID.fromString("f7a1b2c3-d4e5-6789-0abc-def123456789"); + +// Export as an ODCS object var odcs = client.dataContracts().exportToODCS(contractId); System.out.println("ODCS version: " + odcs.getApiVersion()); +System.out.println("Status: " + odcs.getStatus()); // Export as YAML String yaml = client.dataContracts().exportToODCSYaml(contractId); + +// Export by fully qualified name +var byName = client.dataContracts().exportToODCSByFqn( + "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract"); ``` ```bash Export ODCS @@ -86,7 +96,7 @@ curl "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/odcs/ -H "Accept: application/yaml" # Export by FQN -curl "{base_url}/api/v1/dataContracts/name/sales-orders-contract/odcs" \ +curl "{base_url}/api/v1/dataContracts/name/sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract/odcs" \ -H "Authorization: Bearer {access_token}" ``` @@ -198,7 +208,7 @@ curl "{base_url}/api/v1/dataContracts/name/sales-orders-contract/odcs" \ - Type of the entity (e.g., `table`, `topic`, `apiEndpoint`). + Type of the entity, for example `table`, `topic`, `apiEndpoint`. @@ -236,20 +246,43 @@ contract = (DataContracts.import_odcs(table_id, "table") ``` ```java Import ODCS -// Import from ODCS JSON -var contract = client.dataContracts().importFromODCS( - odcsContract, entityId, "table" -); - -// Import from YAML -var contract = client.dataContracts().importFromODCSYaml( - yamlContent, entityId, "table" -); - -// Import from YAML, keeping quality rules without creating test cases -var contract = client.dataContracts().importFromODCSYaml( - yamlContent, entityId, "table", false -); +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.UUID; +import org.openmetadata.schema.entity.data.DataContract; +import org.openmetadata.sdk.network.HttpMethod; +import org.openmetadata.sdk.network.RequestOptions; + +// client is an initialized OpenMetadataClient. +var entityId = UUID.fromString("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +String yamlContent = Files.readString(Path.of("contract.yaml")); + +// Import from an ODCS object (creates a new contract). +// odcsContract is an ODCSDataContract, for example one returned by exportToODCS. +var imported = client.dataContracts().importFromODCS(odcsContract, entityId, "table"); + +// Import from YAML (creates a new contract) +var importedFromYaml = client.dataContracts().importFromODCSYaml( + yamlContent, entityId, "table"); + +// Update an existing contract from YAML with smart merge +var merged = client.dataContracts().createOrUpdateFromODCSYaml( + yamlContent, entityId, "table"); + +// Replace an existing contract from YAML +var replaced = client.dataContracts().createOrUpdateFromODCSYaml( + yamlContent, entityId, "table", "replace"); + +// Import from YAML, keeping quality rules without creating test cases. +// The SDK method has no createTestCases option, so call the endpoint directly. +var options = RequestOptions.builder() + .queryParam("entityId", entityId.toString()) + .queryParam("entityType", "table") + .queryParam("createTestCases", "false") + .header("Content-Type", "application/yaml") + .build(); +var withoutTestCases = client.getHttpClient().execute( + HttpMethod.POST, "/v1/dataContracts/odcs/yaml", yamlContent, DataContract.class, options); ``` ```bash Import ODCS @@ -370,11 +403,32 @@ curl -X POST "{base_url}/api/v1/dataContracts/odcs/validate/yaml?entityId=a1b2c3 ``` ```java Validate YAML -ContractValidation validation = client.dataContracts().validateODCSYaml( - yamlContent, entityId, "table", true -); -ODCSImportReport report = validation.getOdcsImportReport(); -System.out.println("Can import: " + report.getCanImport()); +import com.fasterxml.jackson.databind.ObjectMapper; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; +import org.openmetadata.sdk.network.RequestOptions; + +// client is an initialized OpenMetadataClient. +var entityId = UUID.fromString("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +String yamlContent = Files.readString(Path.of("contract.yaml")); + +var validation = client.dataContracts().validateODCSYaml(yamlContent, entityId, "table"); +System.out.println("Valid: " + validation.getValid()); + +// The SDK model has no createTestCases option or import report, +// so call the endpoint directly to read the report. +var options = RequestOptions.builder() + .queryParam("entityId", entityId.toString()) + .queryParam("entityType", "table") + .queryParam("createTestCases", "true") + .header("Content-Type", "application/yaml") + .build(); +String response = client.getHttpClient().executeForString( + HttpMethod.POST, "/v1/dataContracts/odcs/validate/yaml", yamlContent, options); +var report = new ObjectMapper().readTree(response).path("odcsImportReport"); +System.out.println("Can import: " + report.path("canImport").asBoolean()); ``` ```json Response diff --git a/v2.0.x/api-reference/data-contracts/retrieve.mdx b/v2.0.x/api-reference/data-contracts/retrieve.mdx index 31b1b0565..03f365513 100644 --- a/v2.0.x/api-reference/data-contracts/retrieve.mdx +++ b/v2.0.x/api-reference/data-contracts/retrieve.mdx @@ -36,7 +36,7 @@ Use `GET /v1/dataContracts/entity` to get the effective contract for an entity, - Type of the entity (e.g., `table`, `topic`, `dashboard`). + Type of the entity, for example `table`, `topic`, `dashboard`. @@ -54,17 +54,17 @@ configure( ) # Get by ID -contract = DataContracts.get("f7a1b2c3-d4e5-6789-0abc-def123456789") -print(f"{contract.name}: {contract.entityStatus}") +contract = DataContracts.retrieve("f7a1b2c3-d4e5-6789-0abc-def123456789") +print(f"{contract.name.root}: {contract.entityStatus}") # Get by FQN -contract = DataContracts.get_by_name("sales-orders-contract") +contract = DataContracts.retrieve_by_name("sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract") # Get effective contract for an entity (includes inherited properties) -contract = DataContracts.get(params={ - "entityId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "entityType": "table" -}) +contract = DataContracts.get_by_entity( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + "table" +) ``` ```java GET /v1/dataContracts/{id} @@ -77,7 +77,7 @@ FluentDataContract contract = find(contractId) System.out.println(contract.getFqn()); // Get by FQN -FluentDataContract contract = findByName("sales-orders-contract") +FluentDataContract contract = findByName("sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract") .includeAll() .fetch(); @@ -92,7 +92,7 @@ curl "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789?field -H "Authorization: Bearer {access_token}" # Get by FQN -curl "{base_url}/api/v1/dataContracts/name/sales-orders-contract" \ +curl "{base_url}/api/v1/dataContracts/name/sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract" \ -H "Authorization: Bearer {access_token}" # Get effective contract for an entity (includes inherited) @@ -177,7 +177,7 @@ curl "{base_url}/api/v1/dataContracts/entity?entityId=a1b2c3d4-e5f6-7890-abcd-ef - SLA expectations (refresh frequency, latency, availability). + SLA expectations (refresh frequency, maximum latency, availability time, time zone, and retention). diff --git a/v2.0.x/api-reference/data-contracts/update.mdx b/v2.0.x/api-reference/data-contracts/update.mdx index 74eb84740..cf5b26c2e 100644 --- a/v2.0.x/api-reference/data-contracts/update.mdx +++ b/v2.0.x/api-reference/data-contracts/update.mdx @@ -76,7 +76,7 @@ curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456 { "id": "f7a1b2c3-d4e5-6789-0abc-def123456789", "name": "sales-orders-contract", - "fullyQualifiedName": "sales-orders-contract", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "description": "Updated contract for sales orders table", "entityStatus": "Approved", "entity": { diff --git a/v2.0.x/api-reference/data-contracts/validate.mdx b/v2.0.x/api-reference/data-contracts/validate.mdx index d1ad71766..97c2888a4 100644 --- a/v2.0.x/api-reference/data-contracts/validate.mdx +++ b/v2.0.x/api-reference/data-contracts/validate.mdx @@ -32,35 +32,35 @@ Validate the effective contract for a specific entity, including rules inherited - Type of the entity (e.g., `table`, `topic`). + Type of the entity, for example `table`, `topic`. ```python POST /v1/dataContracts/{id}/validate -from metadata.sdk import configure, get_client +from metadata.sdk import client, configure from metadata.sdk.entities import DataContracts configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Validate a specific contract -result = client.post( - f"/dataContracts/{contract_id}/validate" -) +result = rest.post("/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/validate") print(f"Status: {result['contractExecutionStatus']}") # Validate by entity -result = client.post("/dataContracts/entity/validate", params={ - "entityId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "entityType": "table" -}) +result = DataContracts.validate_by_entity( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + "table" +) +print(f"Status: {result.contractExecutionStatus}") ``` ```java POST /v1/dataContracts/{id}/validate import static org.openmetadata.sdk.fluent.DataContracts.*; +import org.openmetadata.schema.entity.datacontract.DataContractResult; // Validate a contract DataContractResult result = forContract(contractId).validate(); @@ -68,7 +68,7 @@ System.out.println("Status: " + result.getContractExecutionStatus()); // Or from a loaded contract FluentDataContract contract = find(contractId).fetch(); -DataContractResult result = contract.validate(); +DataContractResult sameResult = contract.validate(); ``` ```bash POST /v1/dataContracts/{id}/validate @@ -86,7 +86,7 @@ curl -X POST "{base_url}/api/v1/dataContracts/entity/validate?entityId=a1b2c3d4- ```json Response (Validation Result) { "id": "e1f2a3b4-c5d6-7890-ef12-345678901234", - "dataContractFQN": "sales-orders-contract", + "dataContractFQN": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "timestamp": 1769986400000, "contractExecutionStatus": "Success", "schemaValidation": { @@ -163,6 +163,10 @@ Programmatically add a validation result (useful for external validation pipelin ### Body Parameters + + Fully qualified name of the data contract the result belongs to. + + Epoch timestamp (milliseconds) of the validation run. @@ -224,16 +228,17 @@ Programmatically add a validation result (useful for external validation pipelin ```python Add Result -from metadata.sdk import configure, get_client +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Add a validation result -client.put(f"/dataContracts/{contract_id}/results", json={ +rest.put("/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/results", json={ + "dataContractFQN": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "timestamp": 1769986400000, "contractExecutionStatus": "Success", "schemaValidation": {"passed": 4, "failed": 0, "total": 4}, @@ -259,6 +264,7 @@ curl -X PUT "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def12345678 -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ + "dataContractFQN": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "timestamp": 1769986400000, "contractExecutionStatus": "Success", "schemaValidation": {"passed": 4, "failed": 0, "total": 4, "failedFields": []}, diff --git a/v2.0.x/api-reference/data-contracts/versions.mdx b/v2.0.x/api-reference/data-contracts/versions.mdx index b1c46cbc7..f8917e3b1 100644 --- a/v2.0.x/api-reference/data-contracts/versions.mdx +++ b/v2.0.x/api-reference/data-contracts/versions.mdx @@ -20,32 +20,37 @@ Every change to a data contract creates a new version. Use the versions API to l Use `GET /v1/dataContracts/{id}/versions/{version}` to retrieve a specific version. - Version number in `major.minor` format (e.g., `0.1`, `0.2`, `1.0`). + Version number in `major.minor` format, for example `0.1`, `0.2`, `1.0`. ```python GET /v1/dataContracts/{id}/versions -from metadata.sdk import configure +import json + +from metadata.sdk import client, configure from metadata.sdk.entities import DataContracts configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client # List all versions -versions = DataContracts.list_versions("f7a1b2c3-d4e5-6789-0abc-def123456789") -for v in versions: - print(f"v{v.version}: {v.updatedBy} at {v.updatedAt}") +history = rest.get("/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/versions") +for item in history["versions"]: + v = json.loads(item) + print(f"v{v['version']}: {v['updatedBy']} at {v['updatedAt']}") # Get specific version -contract_v1 = DataContracts.get_version( +contract_v1 = DataContracts.get_specific_version( "f7a1b2c3-d4e5-6789-0abc-def123456789", "0.1" ) ``` ```java GET /v1/dataContracts/{id}/versions +// client is an initialized OpenMetadataClient. // List versions using the client var history = client.dataContracts().listVersions(contractId); for (var version : history.getVersions()) { diff --git a/v2.0.x/api-reference/data-quality/test-cases/create.mdx b/v2.0.x/api-reference/data-quality/test-cases/create.mdx index 296e7f9c5..f049557c1 100644 --- a/v2.0.x/api-reference/data-quality/test-cases/create.mdx +++ b/v2.0.x/api-reference/data-quality/test-cases/create.mdx @@ -109,13 +109,13 @@ request = CreateTestCaseRequest( ) test_case = TestCases.create(request) -print(f"Created: {test_case.fullyQualifiedName}") +print(f"Created: {test_case.fullyQualifiedName.root}") ``` ```java POST /v1/dataQuality/testCases import org.openmetadata.sdk.fluent.builders.TestCaseBuilder; -// Use an initialized OpenMetadataClient named client. +// client is an initialized OpenMetadataClient. var testCase = TestCaseBuilder.create(client) .name("column_value_max_to_be_between") .testDefinition("columnValueMaxToBeBetween") diff --git a/v2.0.x/api-reference/data-quality/test-cases/delete.mdx b/v2.0.x/api-reference/data-quality/test-cases/delete.mdx index 6573e1f6b..c63f62160 100644 --- a/v2.0.x/api-reference/data-quality/test-cases/delete.mdx +++ b/v2.0.x/api-reference/data-quality/test-cases/delete.mdx @@ -67,27 +67,34 @@ TestCases.delete( ) # Delete by name -TestCases.delete_by_name( - "sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between" +test_case = TestCases.retrieve_by_name( + "sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between", + fields=["testDefinition", "testSuite"] ) +TestCases.delete(test_case.id) # Restore a soft-deleted test case TestCases.restore("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") ``` ```java DELETE /v1/dataQuality/testCases/{id} -import static org.openmetadata.sdk.fluent.TestCases.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "c1bce355-fa2f-48c6-ab4d-fad722a56ed7"; // Soft delete -TestCases.delete("c1bce355-fa2f-48c6-ab4d-fad722a56ed7").execute(); +client.testCases().delete(id); + +// Restore +client.testCases().restore(id); // Hard delete -TestCases.delete("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") - .hardDelete() - .execute(); +client.testCases().delete(id, Map.of("hardDelete", "true")); -// Restore -TestCases.restore("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); +// Delete by name: look up the ID first +var testCase = client.testCases().getByName("sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between"); +client.testCases().delete(testCase.getId().toString()); ``` ```bash DELETE /v1/dataQuality/testCases/{id} diff --git a/v2.0.x/api-reference/data-quality/test-cases/list.mdx b/v2.0.x/api-reference/data-quality/test-cases/list.mdx index 0674393b9..fe4a50cde 100644 --- a/v2.0.x/api-reference/data-quality/test-cases/list.mdx +++ b/v2.0.x/api-reference/data-quality/test-cases/list.mdx @@ -58,50 +58,52 @@ configure( ) # List first page -cases = TestCases.list(limit=50) -for tc in cases.data: - print(f"{tc.fullyQualifiedName}") +cases = TestCases.list(fields=["testDefinition", "testSuite"], limit=50) +for tc in cases.entities: + print(f"{tc.fullyQualifiedName.root}") # List all with auto-pagination -for tc in TestCases.list_all(): - print(f"{tc.name}: {tc.entityLink}") +for tc in TestCases.list_all(fields=["testDefinition", "testSuite"]): + print(f"{tc.name.root}: {tc.entityLink.root}") # Filter by test suite cases = TestCases.list( - testSuiteId="e86a9a11-852f-4bac-b5a7-993b2bbbb572", - fields=["owners", "testDefinition", "testCaseResult"], + filters={"testSuiteId": "e86a9a11-852f-4bac-b5a7-993b2bbbb572"}, + fields=["owners", "testDefinition", "testSuite", "testCaseResult"], limit=50 ) -for tc in cases.data: - print(f"{tc.name} - {tc.testDefinition.name}") +for tc in cases.entities: + print(f"{tc.name.root} - {tc.testDefinition.name}") # Filter by entity link cases = TestCases.list( - entityLink="<#E::table::sample_data.ecommerce_db.shopify.dim_address>", - fields=["testCaseResult"], + filters={"entityLink": "<#E::table::sample_data.ecommerce_db.shopify.dim_address>"}, + fields=["testDefinition", "testSuite", "testCaseResult"], limit=50 ) ``` ```java GET /v1/dataQuality/testCases -import static org.openmetadata.sdk.fluent.TestCases.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = TestCases.list() - .limit(50) - .execute(); - -for (var tc : result.getData()) { - System.out.println(tc.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.testCases().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } -// Filter by test suite -var result = TestCases.list() - .testSuiteId("e86a9a11-852f-4bac-b5a7-993b2bbbb572") - .fields("owners", "testDefinition", "testCaseResult") - .limit(50) - .execute(); +// Filter by test suite with fields +var filtered = new ListParams() + .addFilter("testSuiteId", "e86a9a11-852f-4bac-b5a7-993b2bbbb572") + .setFields("testCaseResult,testDefinition") + .setLimit(50); +var filteredPage = client.testCases().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/dataQuality/testCases diff --git a/v2.0.x/api-reference/data-quality/test-cases/retrieve.mdx b/v2.0.x/api-reference/data-quality/test-cases/retrieve.mdx index e73bf1ca2..de5188777 100644 --- a/v2.0.x/api-reference/data-quality/test-cases/retrieve.mdx +++ b/v2.0.x/api-reference/data-quality/test-cases/retrieve.mdx @@ -28,7 +28,7 @@ Get a single test case by its unique ID or fully qualified name. Use `GET /v1/dataQuality/testCases/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the test case (e.g., `sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between`). + Fully qualified name of the test case, for example `sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between`. @@ -51,7 +51,7 @@ configure( # Get by ID tc = TestCases.retrieve("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") -print(f"{tc.fullyQualifiedName}: {tc.entityLink}") +print(f"{tc.fullyQualifiedName.root}: {tc.entityLink.root}") # Get by ID with fields tc = TestCases.retrieve( @@ -72,16 +72,21 @@ tc = TestCases.retrieve_by_name( ``` ```java GET /v1/dataQuality/testCases/{id} -import static org.openmetadata.sdk.fluent.TestCases.*; +// client is an initialized OpenMetadataClient. +var testCase = client.testCases().get("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); -// Get by ID -var tc = TestCases.retrieve("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); +// Get by ID with fields +var testCaseWithFields = client.testCases().get( + "c1bce355-fa2f-48c6-ab4d-fad722a56ed7", + "testCaseResult,testDefinition"); + +// Get by fully qualified name +var testCaseByName = client.testCases().getByName("sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between"); // Get by name with fields -var tc = TestCases.retrieveByName( +var testCaseByNameWithFields = client.testCases().getByName( "sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between", - "testCaseResult,testDefinition" -); + "testCaseResult,testDefinition"); ``` ```bash GET /v1/dataQuality/testCases/{id} diff --git a/v2.0.x/api-reference/data-quality/test-cases/update.mdx b/v2.0.x/api-reference/data-quality/test-cases/update.mdx index a0f3190ce..c85b5b34f 100644 --- a/v2.0.x/api-reference/data-quality/test-cases/update.mdx +++ b/v2.0.x/api-reference/data-quality/test-cases/update.mdx @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -78,15 +78,16 @@ tc.parameterValues = [ ] updated = TestCases.update(tc) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dataQuality/testCases/{id} -import static org.openmetadata.sdk.fluent.TestCases.*; +// client is an initialized OpenMetadataClient. +var testCaseId = "c1bce355-fa2f-48c6-ab4d-fad722a56ed7"; +var testCase = client.testCases().get(testCaseId); +testCase.setDescription("Updated: Validates shop_id max value stays between 1 and 200"); -var tc = TestCases.retrieve("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); -tc.setDescription("Updated: Validates shop_id max value stays between 1 and 200"); -var updated = TestCases.update(tc); +var updated = client.testCases().update(testCaseId, testCase); ``` ```bash PATCH /v1/dataQuality/testCases/{id} diff --git a/v2.0.x/api-reference/data-quality/test-cases/versions.mdx b/v2.0.x/api-reference/data-quality/test-cases/versions.mdx index 07c9db125..057c94282 100644 --- a/v2.0.x/api-reference/data-quality/test-cases/versions.mdx +++ b/v2.0.x/api-reference/data-quality/test-cases/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dataQuality/testCases/{id}/versions/{version}` to retrieve a specif - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dataQuality/testCases/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import TestCases @@ -40,7 +42,8 @@ configure( # List all versions versions = TestCases.get_versions("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version tc_v1 = TestCases.get_specific_version( @@ -51,20 +54,18 @@ print(f"Original params: {tc_v1.parameterValues}") ``` ```java GET /v1/dataQuality/testCases/{id}/versions -import static org.openmetadata.sdk.fluent.TestCases.*; +// client is an initialized OpenMetadataClient. +var id = "c1bce355-fa2f-48c6-ab4d-fad722a56ed7"; // List all versions -var history = TestCases.getVersions("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); - +var history = client.testCases().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = TestCases.getSpecificVersion( - "c1bce355-fa2f-48c6-ab4d-fad722a56ed7", - 0.1 -); +var v1 = client.testCases().getVersion(id, 0.1); +System.out.println(v1.getDescription()); ``` ```bash GET /v1/dataQuality/testCases/{id}/versions diff --git a/v2.0.x/api-reference/data-quality/test-definitions/create.mdx b/v2.0.x/api-reference/data-quality/test-definitions/create.mdx index 089699fab..312936dfc 100644 --- a/v2.0.x/api-reference/data-quality/test-definitions/create.mdx +++ b/v2.0.x/api-reference/data-quality/test-definitions/create.mdx @@ -32,7 +32,7 @@ Create a custom test definition to define organization-specific data quality val - Array of data types this test can be applied to (e.g., `STRING`, `INT`, `DOUBLE`, `VARCHAR`, `CHAR`, `TEXT`, `NUMBER`, `FLOAT`, `BOOLEAN`). Only applicable when `entityType` is `COLUMN`. + Array of data types this test can be applied to, for example `STRING`, `INT`, `DOUBLE`, `VARCHAR`, `CHAR`, `TEXT`, `NUMBER`, `FLOAT`, `BOOLEAN`. Only applicable when `entityType` is `COLUMN`. @@ -44,7 +44,7 @@ Create a custom test definition to define organization-specific data quality val - Data type of the parameter (e.g., `INT`, `STRING`, `BOOLEAN`, `ARRAY`, `TABLE`). + Data type of the parameter, for example `INT`, `STRING`, `BOOLEAN`, `ARRAY`, `TABLE`. @@ -92,7 +92,7 @@ Create a custom test definition to define organization-specific data quality val - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -136,21 +136,40 @@ request = CreateTestDefinitionRequest( ) test_def = TestDefinitions.create(request) -print(f"Created: {test_def.name}") +print(f"Created: {test_def.name.root}") ``` ```java POST /v1/dataQuality/testDefinitions -import static org.openmetadata.sdk.fluent.TestDefinitions.*; import java.util.List; - -var testDef = TestDefinitions.builder() - .name("columnValuesToMatchBusinessRule") - .displayName("Column Values To Match Business Rule") - .description("Validates that column values conform to a custom business rule regex pattern") - .entityType("COLUMN") - .testPlatforms(List.of("OpenMetadata")) - .supportedDataTypes(List.of("STRING", "VARCHAR", "TEXT")) - .create(); +import org.openmetadata.schema.api.tests.CreateTestDefinition; +import org.openmetadata.schema.tests.TestCaseParameter; +import org.openmetadata.schema.tests.TestPlatform; +import org.openmetadata.schema.type.ColumnDataType; +import org.openmetadata.schema.type.TestCaseParameterDataType; +import org.openmetadata.schema.type.TestDefinitionEntityType; + +// client is an initialized OpenMetadataClient. +var request = new CreateTestDefinition() + .withName("columnValuesToMatchBusinessRule") + .withDisplayName("Column Values To Match Business Rule") + .withDescription("Validates that column values conform to a custom business rule regex pattern") + .withEntityType(TestDefinitionEntityType.COLUMN) + .withTestPlatforms(List.of(TestPlatform.OPEN_METADATA)) + .withSupportedDataTypes(List.of( + ColumnDataType.STRING, ColumnDataType.VARCHAR, ColumnDataType.TEXT)) + .withParameterDefinition(List.of( + new TestCaseParameter() + .withName("regexPattern") + .withDataType(TestCaseParameterDataType.STRING) + .withRequired(true) + .withDescription("The regex pattern to match against"), + new TestCaseParameter() + .withName("threshold") + .withDataType(TestCaseParameterDataType.INT) + .withRequired(false) + .withDescription("Maximum number of non-matching values allowed"))); + +var testDefinition = client.testDefinitions().create(request); ``` ```bash POST /v1/dataQuality/testDefinitions diff --git a/v2.0.x/api-reference/data-quality/test-definitions/list.mdx b/v2.0.x/api-reference/data-quality/test-definitions/list.mdx index e25f6995f..b93f3888c 100644 --- a/v2.0.x/api-reference/data-quality/test-definitions/list.mdx +++ b/v2.0.x/api-reference/data-quality/test-definitions/list.mdx @@ -32,7 +32,7 @@ List all test definitions with optional filtering and pagination. - Filter by test platform (e.g., `OpenMetadata`). + Filter by test platform, for example `OpenMetadata`. @@ -40,7 +40,7 @@ List all test definitions with optional filtering and pagination. - Filter by supported data type (e.g., `STRING`, `INT`, `DOUBLE`). + Filter by supported data type, for example `STRING`, `INT`, `DOUBLE`. @@ -55,41 +55,43 @@ configure( # List first page definitions = TestDefinitions.list(limit=50) -for td in definitions.data: - print(f"{td.name} ({td.entityType})") +for td in definitions.entities: + print(f"{td.name.root} ({td.entityType.value})") # List all with auto-pagination for td in TestDefinitions.list_all(): - print(f"{td.name}: {td.description}") + print(f"{td.name.root}: {td.description.root}") # Filter by entity type column_defs = TestDefinitions.list( - entityType="COLUMN", + filters={"entityType": "COLUMN"}, fields=["owners"], limit=50 ) -for td in column_defs.data: - print(f"{td.name} - supports: {td.supportedDataTypes}") +for td in column_defs.entities: + print(f"{td.name.root} - supports: {td.supportedDataTypes}") ``` ```java GET /v1/dataQuality/testDefinitions -import static org.openmetadata.sdk.fluent.TestDefinitions.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = TestDefinitions.list() - .limit(50) - .execute(); - -for (var td : result.getData()) { - System.out.println(td.getName() + " (" + td.getEntityType() + ")"); +var params = new ListParams().setLimit(50); +var page = client.testDefinitions().list(params); +for (var item : page.getData()) { + System.out.println(item.getName()); } // Filter by entity type -var result = TestDefinitions.list() - .entityType("COLUMN") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("entityType", "COLUMN") + .setLimit(50); +var filteredPage = client.testDefinitions().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getName()); +} ``` ```bash GET /v1/dataQuality/testDefinitions @@ -186,7 +188,7 @@ Returns a paginated list of test definition objects. Use the `fields` parameter - Supported test platforms (e.g., `OpenMetadata`). + Supported test platforms, for example `OpenMetadata`. @@ -202,7 +204,7 @@ Returns a paginated list of test definition objects. Use the `fields` parameter - Data type of the parameter (e.g., `INT`, `STRING`, `BOOLEAN`). + Data type of the parameter, for example `INT`, `STRING`, `BOOLEAN`. diff --git a/v2.0.x/api-reference/data-quality/test-definitions/retrieve.mdx b/v2.0.x/api-reference/data-quality/test-definitions/retrieve.mdx index 47c77ff3b..02acfc373 100644 --- a/v2.0.x/api-reference/data-quality/test-definitions/retrieve.mdx +++ b/v2.0.x/api-reference/data-quality/test-definitions/retrieve.mdx @@ -16,7 +16,7 @@ Get a single test definition by its unique ID or name. - Comma-separated list of fields to include (e.g., `owners`). + Comma-separated list of fields to include, for example `owners`. @@ -28,7 +28,7 @@ Get a single test definition by its unique ID or name. Use `GET /v1/dataQuality/testDefinitions/name/{name}` to retrieve by name. - Name of the test definition (e.g., `columnValueLengthsToBeBetween`). + Name of the test definition, for example `columnValueLengthsToBeBetween`. @@ -51,7 +51,7 @@ configure( # Get by ID td = TestDefinitions.retrieve("a636d153-f1e8-45be-86d3-52aa6b71730d") -print(f"{td.name}: {td.description}") +print(f"{td.name.root}: {getattr(td.description, 'root', td.description)}") # Get by ID with fields td = TestDefinitions.retrieve( @@ -66,13 +66,11 @@ print(f"Parameters: {[p.name for p in td.parameterDefinition]}") ``` ```java GET /v1/dataQuality/testDefinitions/{id} -import static org.openmetadata.sdk.fluent.TestDefinitions.*; +// client is an initialized OpenMetadataClient. +var testDefinition = client.testDefinitions().get("a636d153-f1e8-45be-86d3-52aa6b71730d"); -// Get by ID -var td = TestDefinitions.retrieve("a636d153-f1e8-45be-86d3-52aa6b71730d"); - -// Get by name -var td = TestDefinitions.retrieveByName("columnValueLengthsToBeBetween"); +// Get by fully qualified name +var testDefinitionByName = client.testDefinitions().getByName("columnValueLengthsToBeBetween"); ``` ```bash GET /v1/dataQuality/testDefinitions/{id} diff --git a/v2.0.x/api-reference/data-quality/test-suites/create.mdx b/v2.0.x/api-reference/data-quality/test-suites/create.mdx index 947d3dc0e..27e76cf08 100644 --- a/v2.0.x/api-reference/data-quality/test-suites/create.mdx +++ b/v2.0.x/api-reference/data-quality/test-suites/create.mdx @@ -66,12 +66,14 @@ request = CreateTestSuiteRequest( ) test_suite = TestSuites.create(request) -print(f"Created: {test_suite.name}") +print(f"Created: {test_suite.name.root}") ``` ```java POST /v1/dataQuality/testSuites import org.openmetadata.sdk.fluent.builders.TestSuiteBuilder; +// client is an initialized OpenMetadataClient. + // Create a logical test suite // Use an initialized OpenMetadataClient named client. var testSuite = new TestSuiteBuilder(client) diff --git a/v2.0.x/api-reference/data-quality/test-suites/delete.mdx b/v2.0.x/api-reference/data-quality/test-suites/delete.mdx index ab805609b..c46c667a0 100644 --- a/v2.0.x/api-reference/data-quality/test-suites/delete.mdx +++ b/v2.0.x/api-reference/data-quality/test-suites/delete.mdx @@ -67,25 +67,30 @@ TestSuites.delete( ) # Delete by name -TestSuites.delete_by_name("b5fcae09-02c2-4c0b-8c4a-5b52d650e592") +TestSuites.delete(TestSuites.retrieve_by_name("sample_data.ecommerce_db.shopify.dim_address.testSuite").id) # Restore a soft-deleted test suite TestSuites.restore("e86a9a11-852f-4bac-b5a7-993b2bbbb572") ``` ```java DELETE /v1/dataQuality/testSuites/{id} -import static org.openmetadata.sdk.fluent.TestSuites.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "e86a9a11-852f-4bac-b5a7-993b2bbbb572"; // Soft delete -TestSuites.delete("e86a9a11-852f-4bac-b5a7-993b2bbbb572").execute(); +client.testSuites().delete(id); + +// Restore +client.testSuites().restore(id); // Hard delete -TestSuites.delete("e86a9a11-852f-4bac-b5a7-993b2bbbb572") - .hardDelete() - .execute(); +client.testSuites().delete(id, Map.of("hardDelete", "true")); -// Restore -TestSuites.restore("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); +// Delete by name: look up the ID first +var testSuite = client.testSuites().getByName("sample_data.ecommerce_db.shopify.dim_address.testSuite"); +client.testSuites().delete(testSuite.getId().toString()); ``` ```bash DELETE /v1/dataQuality/testSuites/{id} @@ -98,7 +103,7 @@ curl -X DELETE "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7 -H "Authorization: Bearer {access_token}" # Delete by name -curl -X DELETE "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52d650e592" \ +curl -X DELETE "{base_url}/api/v1/dataQuality/testSuites/name/sample_data.ecommerce_db.shopify.dim_address.testSuite" \ -H "Authorization: Bearer {access_token}" # Restore soft-deleted test suite @@ -113,15 +118,15 @@ curl -X PUT "{base_url}/api/v1/dataQuality/testSuites/restore" \ ```json Response (Soft Delete) { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "version": 0.2, "updatedAt": 1769982800000, "updatedBy": "admin", "deleted": true, "owners": [], - "executable": true + "basic": true } ``` diff --git a/v2.0.x/api-reference/data-quality/test-suites/list.mdx b/v2.0.x/api-reference/data-quality/test-suites/list.mdx index 4e2742e3d..37e60d98a 100644 --- a/v2.0.x/api-reference/data-quality/test-suites/list.mdx +++ b/v2.0.x/api-reference/data-quality/test-suites/list.mdx @@ -32,7 +32,7 @@ List all test suites with optional filtering and pagination. - Filter by test suite type: `executable` or `logical`. + Filter by test suite type, for example `logical`. The older value `executable` is still accepted. @@ -47,42 +47,44 @@ configure( # List first page suites = TestSuites.list(limit=50) -for ts in suites.data: - print(f"{ts.displayName} (executable: {ts.executable})") +for ts in suites.entities: + print(f"{ts.displayName} (basic: {ts.basic})") # List all with auto-pagination for ts in TestSuites.list_all(): - print(f"{ts.fullyQualifiedName}") + print(f"{ts.fullyQualifiedName.root}") # Filter by type logical_suites = TestSuites.list( - testSuiteType="logical", + filters={"testSuiteType": "logical"}, fields=["owners", "tests"], limit=50 ) -for ts in logical_suites.data: +for ts in logical_suites.entities: print(f"{ts.displayName}") ``` ```java GET /v1/dataQuality/testSuites -import static org.openmetadata.sdk.fluent.TestSuites.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = TestSuites.list() - .limit(50) - .execute(); - -for (var ts : result.getData()) { - System.out.println(ts.getDisplayName()); +var params = new ListParams().setLimit(50); +var page = client.testSuites().list(params); +for (var item : page.getData()) { + System.out.println(item.getDisplayName()); } -// Filter by type -var result = TestSuites.list() - .testSuiteType("logical") - .fields("owners", "tests") - .limit(50) - .execute(); +// Filter by type with fields +var filtered = new ListParams() + .addFilter("testSuiteType", "logical") + .setFields("owners,tests") + .setLimit(50); +var filteredPage = client.testSuites().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getDisplayName()); +} ``` ```bash GET /v1/dataQuality/testSuites @@ -91,7 +93,7 @@ curl "{base_url}/api/v1/dataQuality/testSuites?limit=50" \ -H "Authorization: Bearer {access_token}" # Filter by type -curl "{base_url}/api/v1/dataQuality/testSuites?testSuiteType=executable&limit=50" \ +curl "{base_url}/api/v1/dataQuality/testSuites?testSuiteType=logical&limit=50" \ -H "Authorization: Bearer {access_token}" # With fields @@ -106,15 +108,15 @@ curl "{base_url}/api/v1/dataQuality/testSuites?fields=owners,tests&limit=50" \ "data": [ { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "version": 0.1, "updatedAt": 1769982757893, "updatedBy": "admin", "deleted": false, "owners": [], - "executable": true + "basic": true } ], "paging": { @@ -153,8 +155,8 @@ Returns a paginated list of test suite objects. Use the `fields` parameter to re Human-readable display name. - - Whether this is an executable or logical test suite. + + `true` for a table-level (basic) test suite, `false` for a logical test suite. diff --git a/v2.0.x/api-reference/data-quality/test-suites/retrieve.mdx b/v2.0.x/api-reference/data-quality/test-suites/retrieve.mdx index f57b6d414..f906e54ae 100644 --- a/v2.0.x/api-reference/data-quality/test-suites/retrieve.mdx +++ b/v2.0.x/api-reference/data-quality/test-suites/retrieve.mdx @@ -51,7 +51,7 @@ configure( # Get by ID ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572") -print(f"{ts.displayName} (executable: {ts.executable})") +print(f"{ts.displayName} (basic: {ts.basic})") # Get by ID with fields ts = TestSuites.retrieve( @@ -60,20 +60,25 @@ ts = TestSuites.retrieve( ) # Get by fully qualified name -ts = TestSuites.retrieve_by_name("b5fcae09-02c2-4c0b-8c4a-5b52d650e592") +ts = TestSuites.retrieve_by_name("sample_data.ecommerce_db.shopify.dim_address.testSuite") ``` ```java GET /v1/dataQuality/testSuites/{id} -import static org.openmetadata.sdk.fluent.TestSuites.*; +// client is an initialized OpenMetadataClient. +var testSuite = client.testSuites().get("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); -// Get by ID -var ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); +// Get by ID with fields +var testSuiteWithFields = client.testSuites().get( + "e86a9a11-852f-4bac-b5a7-993b2bbbb572", + "owners,tests"); + +// Get by fully qualified name +var testSuiteByName = client.testSuites().getByName("sample_data.ecommerce_db.shopify.dim_address.testSuite"); // Get by name with fields -var ts = TestSuites.retrieveByName( - "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", - "owners,tests" -); +var testSuiteByNameWithFields = client.testSuites().getByName( + "sample_data.ecommerce_db.shopify.dim_address.testSuite", + "owners,tests"); ``` ```bash GET /v1/dataQuality/testSuites/{id} @@ -86,7 +91,7 @@ curl "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7-993b2bbbb -H "Authorization: Bearer {access_token}" # Get by name -curl "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52d650e592" \ +curl "{base_url}/api/v1/dataQuality/testSuites/name/sample_data.ecommerce_db.shopify.dim_address.testSuite" \ -H "Authorization: Bearer {access_token}" ``` @@ -95,15 +100,15 @@ curl "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52 ```json Response { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "version": 0.1, "updatedAt": 1769982757893, "updatedBy": "admin", "deleted": false, "owners": [], - "executable": true + "basic": true } ``` @@ -136,8 +141,8 @@ Returns a test suite object with all requested fields populated. Description of the test suite. - - Whether this is an executable or logical test suite. + + `true` for a table-level (basic) test suite, `false` for a logical test suite. diff --git a/v2.0.x/api-reference/data-quality/test-suites/update.mdx b/v2.0.x/api-reference/data-quality/test-suites/update.mdx index 08ff81e81..ac37d5a1a 100644 --- a/v2.0.x/api-reference/data-quality/test-suites/update.mdx +++ b/v2.0.x/api-reference/data-quality/test-suites/update.mdx @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -64,16 +64,16 @@ ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572") ts.description = "Updated: Critical data quality checks for production tables" updated = TestSuites.update(ts) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dataQuality/testSuites/{id} -import static org.openmetadata.sdk.fluent.TestSuites.*; +// client is an initialized OpenMetadataClient. +var testSuiteId = "e86a9a11-852f-4bac-b5a7-993b2bbbb572"; +var testSuite = client.testSuites().get(testSuiteId); +testSuite.setDescription("Updated: Critical data quality checks for production tables"); -// Retrieve, modify, and update -var ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); -ts.setDescription("Updated: Critical data quality checks for production tables"); -var updated = TestSuites.update(ts); +var updated = client.testSuites().update(testSuiteId, testSuite); ``` ```bash PATCH /v1/dataQuality/testSuites/{id} @@ -86,7 +86,7 @@ curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7- ]' # Update by name -curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52d650e592" \ +curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/name/sample_data.ecommerce_db.shopify.dim_address.testSuite" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json-patch+json" \ -d '[ @@ -99,16 +99,16 @@ curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b- ```json Response { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "description": "Updated: Critical data quality checks for production tables", "version": 0.2, "updatedAt": 1769982800000, "updatedBy": "admin", "deleted": false, "owners": [], - "executable": true + "basic": true } ``` diff --git a/v2.0.x/api-reference/data-quality/test-suites/versions.mdx b/v2.0.x/api-reference/data-quality/test-suites/versions.mdx index 79e7b4dbf..6e5793a74 100644 --- a/v2.0.x/api-reference/data-quality/test-suites/versions.mdx +++ b/v2.0.x/api-reference/data-quality/test-suites/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dataQuality/testSuites/{id}/versions/{version}` to retrieve a speci - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dataQuality/testSuites/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import TestSuites @@ -40,31 +42,30 @@ configure( # List all versions versions = TestSuites.get_versions("e86a9a11-852f-4bac-b5a7-993b2bbbb572") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version ts_v1 = TestSuites.get_specific_version( "e86a9a11-852f-4bac-b5a7-993b2bbbb572", "0.1" ) -print(f"Original description: {ts_v1.description}") +print(f"Original description: {getattr(ts_v1.description, 'root', ts_v1.description)}") ``` ```java GET /v1/dataQuality/testSuites/{id}/versions -import static org.openmetadata.sdk.fluent.TestSuites.*; +// client is an initialized OpenMetadataClient. +var id = "e86a9a11-852f-4bac-b5a7-993b2bbbb572"; // List all versions -var history = TestSuites.getVersions("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); - +var history = client.testSuites().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = TestSuites.getSpecificVersion( - "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - 0.1 -); +var v1 = client.testSuites().getVersion(id, 0.1); +System.out.println(v1.getDescription()); ``` ```bash GET /v1/dataQuality/testSuites/{id}/versions @@ -83,8 +84,8 @@ curl "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7-993b2bbbb { "entityType": "testSuite", "versions": [ - "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"b5fcae09-02c2-4c0b-8c4a-5b52d650e592\",\"version\":0.2,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"description\":\"Updated description\",\"executable\":true}", - "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"b5fcae09-02c2-4c0b-8c4a-5b52d650e592\",\"version\":0.1,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"executable\":true}" + "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"sample_data.ecommerce_db.shopify.dim_address.testSuite\",\"version\":0.2,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"description\":\"Updated description\",\"basic\":true}", + "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"sample_data.ecommerce_db.shopify.dim_address.testSuite\",\"version\":0.1,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"basic\":true}" ] } ``` diff --git a/v2.0.x/api-reference/discovery/field-query.mdx b/v2.0.x/api-reference/discovery/field-query.mdx index 6c440f7ff..0c5990dd3 100644 --- a/v2.0.x/api-reference/discovery/field-query.mdx +++ b/v2.0.x/api-reference/discovery/field-query.mdx @@ -33,31 +33,35 @@ Search for entities by matching a specific field to a given value. This is usefu ```python GET /v1/search/fieldQuery -from metadata.sdk import configure, get_client +from urllib.parse import urlencode + +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Find tables with a specific column name -response = client.get("/search/fieldQuery", params={ +params = urlencode({ "fieldName": "columns.name", "fieldValue": "shop_id", "index": "table_search_index" }) +response = rest.get(f"/search/fieldQuery?{params}") for hit in response["hits"]["hits"]: entity = hit["_source"] print(f"{entity['fullyQualifiedName']} (score: {hit['_score']})") # Find entities with a specific tag -response = client.get("/search/fieldQuery", params={ +params = urlencode({ "fieldName": "tags.tagFQN", "fieldValue": "PII.Sensitive", "index": "table_search_index" }) +response = rest.get(f"/search/fieldQuery?{params}") for hit in response["hits"]["hits"]: entity = hit["_source"] @@ -65,6 +69,7 @@ for hit in response["hits"]["hits"]: ``` ```java GET /v1/search/fieldQuery +// client is an initialized OpenMetadataClient. // Find tables with a specific column name var response = client.searchApi().fieldQuery( "columns.name", // fieldName @@ -205,7 +210,7 @@ Returns an Elasticsearch-style response containing entities where the specified | Field Path | Description | Applicable Indexes | |------------|-------------|-------------------| | `columns.name` | Column name within a table | `table_search_index` | -| `tags.tagFQN` | Fully qualified tag name (e.g., `PII.Sensitive`) | All indexes | +| `tags.tagFQN` | Fully qualified tag name, for example `PII.Sensitive` | All indexes | | `owners.name` | Owner username | All indexes | | `service.name` | Service name | All entity indexes | | `database.name` | Database name | `table_search_index` | diff --git a/v2.0.x/api-reference/discovery/search.mdx b/v2.0.x/api-reference/discovery/search.mdx index ba66c99ca..0a26d0060 100644 --- a/v2.0.x/api-reference/discovery/search.mdx +++ b/v2.0.x/api-reference/discovery/search.mdx @@ -32,7 +32,7 @@ Full-text search across all entity types in the metadata catalog. Uses Elasticse - Field to sort by (e.g., `name`, `updatedAt`, `totalVotes`). + Field to sort by, for example `name`, `updatedAt`, `totalVotes`. @@ -65,21 +65,24 @@ Full-text search across all entity types in the metadata catalog. Uses Elasticse ```python GET /v1/search/query -from metadata.sdk import configure, get_client +from urllib.parse import urlencode + +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Search for tables matching "customer" -response = client.get("/search/query", params={ +params = urlencode({ "q": "customer", "index": "table_search_index", "from": 0, "size": 10 }) +response = rest.get(f"/search/query?{params}") for hit in response["hits"]["hits"]: entity = hit["_source"] @@ -87,6 +90,7 @@ for hit in response["hits"]["hits"]: ``` ```java GET /v1/search/query +// client is an initialized OpenMetadataClient. // Search using the OpenMetadata client var response = client.searchApi().searchEntities( "customer", // query @@ -207,7 +211,7 @@ Returns an Elasticsearch-style response containing matched entities ranked by re - Search index the result was found in (e.g., `table_search_index`). + Search index the result was found in, for example `table_search_index`. diff --git a/v2.0.x/api-reference/errors.mdx b/v2.0.x/api-reference/errors.mdx index 4356e8643..e2a6decea 100644 --- a/v2.0.x/api-reference/errors.mdx +++ b/v2.0.x/api-reference/errors.mdx @@ -278,15 +278,14 @@ except Exception as e: ``` ```java JAVA SDK -import org.openmetadata.client.api.TablesApi; -import org.openmetadata.client.ApiException; +import org.openmetadata.sdk.exceptions.OpenMetadataException; -TablesApi tablesApi = client.buildClient(TablesApi.class); +// client is an initialized OpenMetadataClient. try { - Table table = tablesApi.getTableByFQN("prod.analytics.customers", null, null); -} catch (ApiException e) { - switch (e.getCode()) { + var table = client.tables().getByName("prod.analytics.customers"); +} catch (OpenMetadataException e) { + switch (e.getStatusCode()) { case 404: System.out.println("Table not found"); break; diff --git a/v2.0.x/api-reference/getting-started.mdx b/v2.0.x/api-reference/getting-started.mdx index 4a180d1de..fc7fc3f14 100644 --- a/v2.0.x/api-reference/getting-started.mdx +++ b/v2.0.x/api-reference/getting-started.mdx @@ -9,10 +9,14 @@ import BotsTileAdminNote from '/snippets/deployment/bots-tile-admin-note.mdx' Get up and running with the OpenMetadata API and SDKs. This guide walks you through authentication, SDK installation, and making your first API call. + +Most Python examples in this API reference use SDK 2.0 (`metadata.sdk`). The Topics and ML model services pages use the original client, because SDK 2.0 has no class for them. The pages under the SDK section also show the original client. For more information, see [Which Python SDK Should I Use?](/v2.0.x/api-reference/sdk/python/overview#which-python-sdk-should-i-use). + + ## Prerequisites - A OpenMetadata account (cloud or self-hosted instance) -- Your instance base URL (e.g., `https://your-company.open-metadata.org/api`) +- Your instance base URL, for example `https://your-company.open-metadata.org/api` - **Python 3.11+**, **Java 21+**, or **Go 1.19+** (depending on your SDK choice) @@ -81,23 +85,13 @@ Set up the connection to your OpenMetadata instance: ```python Python -from metadata.ingestion.ometa.ometa_api import OpenMetadata -from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( - OpenMetadataConnection, -) -from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( - OpenMetadataJWTClientConfig, -) +from metadata.sdk import configure -server_config = OpenMetadataConnection( - hostPort="https://your-company.open-metadata.org/api", - authProvider="openmetadata", - securityConfig=OpenMetadataJWTClientConfig( - jwtToken="your-jwt-token" - ), +# The host must end with /api +configure( + host="https://your-company.open-metadata.org/api", + jwt_token="your-jwt-token", ) - -metadata = OpenMetadata(server_config) ``` ```java Java @@ -115,15 +109,10 @@ OpenMetadataClient client = new OpenMetadataClient(config); ```go Go import ometa "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" -restConfig := ometa.NewRestConfig( +client := ometa.NewClient( "https://your-company.open-metadata.org", - "", // APIVersion - 0, // Retry -> defaults to 3 - 0, // RetryWait -> defaults to 30 seconds - nil, // RetryCodes -> defaults to [429, 504] - "your-jwt-token", + ometa.WithToken("your-jwt-token"), ) -client, err := ometa.NewRest(restConfig) ``` ```bash cURL @@ -141,40 +130,32 @@ List the tables in your catalog to verify everything is working: ```python Python -from metadata.generated.schema.entity.data.table import Table +from metadata.sdk import Tables -tables = metadata.list_all_entities(entity=Table) -for table in tables: - print(f"{table.fullyQualifiedName}: {table.description}") +for table in Tables.list_all(): + print(f"{table.fullyQualifiedName.root}: {getattr(table.description, 'root', table.description)}") ``` ```java Java -TablesApi tablesApi = client.buildClient(TablesApi.class); -TableList tables = tablesApi.listTables(null, 10, null, null, null); +import org.openmetadata.sdk.models.ListParams; -for (Table table : tables.getData()) { +// client is an initialized OpenMetadataClient. + +var tables = client.tables().list(new ListParams().setLimit(10)); + +for (var table : tables.getData()) { System.out.println(table.getFullyQualifiedName()); } ``` ```go Go -resp, err := rest.Get("tables", map[string]string{"limit": "10"}) -if err != nil { - log.Fatal(err) -} -defer resp.Body.Close() +ctx := context.Background() -var result struct { - Data []struct { - FullyQualifiedName string `json:"fullyQualifiedName"` - } `json:"data"` -} -if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { - log.Fatal(err) -} - -for _, table := range result.Data { - fmt.Println(table.FullyQualifiedName) +for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(*table.FullyQualifiedName) } ``` @@ -224,7 +205,7 @@ from metadata.generated.schema.api.data.createTable import CreateTableRequest from metadata.generated.schema.entity.data.table import Column, DataType # Initialize the SDK -configure(host="https://your-company.open-metadata.org", jwt_token="your-jwt-token") +configure(host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token") # Create and persist the table table = Tables.create(CreateTableRequest( @@ -238,15 +219,15 @@ table = Tables.create(CreateTableRequest( ], )) -print(f"Created: {table.fullyQualifiedName}") +print(f"Created: {table.fullyQualifiedName.root}") ``` ```java Java -import org.openmetadata.sdk.client.OpenMetadataClient; -import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.schema.entity.data.Table; import org.openmetadata.sdk.fluent.builders.TableBuilder; import org.openmetadata.sdk.fluent.builders.ColumnBuilder; +// client is the OpenMetadataClient from the "Initialize Your Client" step. // Create and persist the table in one fluent chain Table table = new TableBuilder(client) .name("customers") diff --git a/v2.0.x/api-reference/governance/classifications/create.mdx b/v2.0.x/api-reference/governance/classifications/create.mdx index 706006bf0..a3855388f 100644 --- a/v2.0.x/api-reference/governance/classifications/create.mdx +++ b/v2.0.x/api-reference/governance/classifications/create.mdx @@ -36,7 +36,7 @@ Create a new classification for organizing tags into categories. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -67,18 +67,19 @@ request = CreateClassificationRequest( ) classification = Classifications.create(request) -print(f"Created: {classification.fullyQualifiedName}") +print(f"Created: {classification.fullyQualifiedName.root}") ``` ```java POST /v1/classifications -import static org.openmetadata.sdk.fluent.Classifications.*; - -// Create using builder pattern -var classification = Classifications.builder() - .name("Certification") - .description("Certifying Data Asset will provide the users with a clear idea of...") - .mutuallyExclusive(true) - .create(); +import org.openmetadata.schema.api.classification.CreateClassification; + +// client is an initialized OpenMetadataClient. +var request = new CreateClassification() + .withName("Certification") + .withDescription("Certifying Data Asset will provide the users with a clear idea of...") + .withMutuallyExclusive(true); + +var classification = client.classifications().create(request); ``` ```bash POST /v1/classifications diff --git a/v2.0.x/api-reference/governance/classifications/delete.mdx b/v2.0.x/api-reference/governance/classifications/delete.mdx index f1502e18d..662141382 100644 --- a/v2.0.x/api-reference/governance/classifications/delete.mdx +++ b/v2.0.x/api-reference/governance/classifications/delete.mdx @@ -28,7 +28,7 @@ Delete a classification by ID or fully qualified name. Supports soft delete (def Use `DELETE /v1/classifications/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the classification (e.g., `Certification`). + Fully qualified name of the classification, for example `Certification`. @@ -67,28 +67,30 @@ Classifications.delete( ) # Delete by name -Classifications.delete_by_name("Certification") +Classifications.delete(Classifications.retrieve_by_name("Certification").id) # Restore a soft-deleted classification Classifications.restore("06d90883-6be9-4f7e-9475-753f10a95e94") ``` ```java DELETE /v1/classifications/{id} -import static org.openmetadata.sdk.fluent.Classifications.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "06d90883-6be9-4f7e-9475-753f10a95e94"; // Soft delete -Classifications.delete("06d90883-6be9-4f7e-9475-753f10a95e94").execute(); +client.classifications().delete(id); -// Hard delete -Classifications.delete("06d90883-6be9-4f7e-9475-753f10a95e94") - .hardDelete() - .execute(); +// Restore +client.classifications().restore(id); -// Delete by name -Classifications.deleteByName("Certification").execute(); +// Hard delete +client.classifications().delete(id, Map.of("hardDelete", "true")); -// Restore -Classifications.restore("06d90883-6be9-4f7e-9475-753f10a95e94"); +// Delete by name: look up the ID first +var classification = client.classifications().getByName("Certification"); +client.classifications().delete(classification.getId().toString()); ``` ```bash DELETE /v1/classifications/{id} diff --git a/v2.0.x/api-reference/governance/classifications/list.mdx b/v2.0.x/api-reference/governance/classifications/list.mdx index 28e5770f3..43152296a 100644 --- a/v2.0.x/api-reference/governance/classifications/list.mdx +++ b/v2.0.x/api-reference/governance/classifications/list.mdx @@ -43,12 +43,12 @@ configure( # List first page classifications = Classifications.list(limit=50) -for c in classifications.data: - print(f"{c.fullyQualifiedName} (mutuallyExclusive: {c.mutuallyExclusive})") +for c in classifications.entities: + print(f"{c.fullyQualifiedName.root} (mutuallyExclusive: {c.mutuallyExclusive})") # List all with auto-pagination for c in Classifications.list_all(): - print(f"{c.fullyQualifiedName}") + print(f"{c.fullyQualifiedName.root}") # With fields classifications = Classifications.list( @@ -58,22 +58,24 @@ classifications = Classifications.list( ``` ```java GET /v1/classifications -import static org.openmetadata.sdk.fluent.Classifications.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Classifications.list() - .limit(50) - .execute(); - -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.classifications().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // With fields -var result = Classifications.list() - .fields("owners") - .limit(50) - .execute(); +var filtered = new ListParams() + .setFields("owners") + .setLimit(50); +var filteredPage = client.classifications().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/classifications diff --git a/v2.0.x/api-reference/governance/classifications/retrieve.mdx b/v2.0.x/api-reference/governance/classifications/retrieve.mdx index 75868f41c..e9e69d1a9 100644 --- a/v2.0.x/api-reference/governance/classifications/retrieve.mdx +++ b/v2.0.x/api-reference/governance/classifications/retrieve.mdx @@ -16,7 +16,7 @@ Get a single classification by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners`). + Comma-separated list of fields to include, for example `owners`. @@ -28,7 +28,7 @@ Get a single classification by its unique ID or fully qualified name. Use `GET /v1/classifications/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the classification (e.g., `Certification`). + Fully qualified name of the classification, for example `Certification`. @@ -51,7 +51,7 @@ configure( # Get by ID classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94") -print(f"{classification.fullyQualifiedName}: {classification.description}") +print(f"{classification.fullyQualifiedName.root}: {getattr(classification.description, 'root', classification.description)}") # Get by ID with fields classification = Classifications.retrieve( @@ -70,22 +70,21 @@ classification = Classifications.retrieve_by_name( ``` ```java GET /v1/classifications/{id} -import static org.openmetadata.sdk.fluent.Classifications.*; - -// Get by ID -var classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94"); +// client is an initialized OpenMetadataClient. +var classification = client.classifications().get("06d90883-6be9-4f7e-9475-753f10a95e94"); // Get by ID with fields -var classification = Classifications.retrieve( +var classificationWithFields = client.classifications().get( "06d90883-6be9-4f7e-9475-753f10a95e94", - "owners" -); + "owners"); // Get by fully qualified name -var classification = Classifications.retrieveByName("Certification"); +var classificationByName = client.classifications().getByName("Certification"); // Get by name with fields -var classification = Classifications.retrieveByName("Certification", "owners"); +var classificationByNameWithFields = client.classifications().getByName( + "Certification", + "owners"); ``` ```bash GET /v1/classifications/{id} diff --git a/v2.0.x/api-reference/governance/classifications/update.mdx b/v2.0.x/api-reference/governance/classifications/update.mdx index 98468f05b..870cb318b 100644 --- a/v2.0.x/api-reference/governance/classifications/update.mdx +++ b/v2.0.x/api-reference/governance/classifications/update.mdx @@ -20,7 +20,7 @@ Update a classification's properties using JSON Merge Patch. You can update by I Use `PATCH /v1/classifications/name/{fqn}` to update by fully qualified name. - Fully qualified name of the classification (e.g., `Certification`). + Fully qualified name of the classification, for example `Certification`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,16 +68,16 @@ classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94" classification.description = "Updated: Classification for data asset certification levels" updated = Classifications.update(classification) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/classifications/{id} -import static org.openmetadata.sdk.fluent.Classifications.*; - -// Retrieve, modify, and update -var classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94"); +// client is an initialized OpenMetadataClient. +var classificationId = "06d90883-6be9-4f7e-9475-753f10a95e94"; +var classification = client.classifications().get(classificationId); classification.setDescription("Updated: Classification for data asset certification levels"); -var updated = Classifications.update(classification); + +var updated = client.classifications().update(classificationId, classification); ``` ```bash PATCH /v1/classifications/{id} diff --git a/v2.0.x/api-reference/governance/classifications/versions.mdx b/v2.0.x/api-reference/governance/classifications/versions.mdx index d64423ddc..5ded3810d 100644 --- a/v2.0.x/api-reference/governance/classifications/versions.mdx +++ b/v2.0.x/api-reference/governance/classifications/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/classifications/{id}/versions/{version}` to retrieve a specific ver - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/classifications/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Classifications @@ -40,31 +42,29 @@ configure( # List all versions versions = Classifications.get_versions("06d90883-6be9-4f7e-9475-753f10a95e94") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version classification_v1 = Classifications.get_specific_version( "06d90883-6be9-4f7e-9475-753f10a95e94", "0.1" ) -print(f"Original description: {classification_v1.description}") +print(f"Original description: {getattr(classification_v1.description, 'root', classification_v1.description)}") ``` ```java GET /v1/classifications/{id}/versions -import static org.openmetadata.sdk.fluent.Classifications.*; +// client is an initialized OpenMetadataClient. +var id = "06d90883-6be9-4f7e-9475-753f10a95e94"; // List all versions -var history = Classifications.getVersions("06d90883-6be9-4f7e-9475-753f10a95e94"); - +var history = client.classifications().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Classifications.getSpecificVersion( - "06d90883-6be9-4f7e-9475-753f10a95e94", - 0.1 -); +var v1 = client.classifications().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/governance/data-products/create.mdx b/v2.0.x/api-reference/governance/data-products/create.mdx index e6d6b59a4..44124a47e 100644 --- a/v2.0.x/api-reference/governance/data-products/create.mdx +++ b/v2.0.x/api-reference/governance/data-products/create.mdx @@ -12,11 +12,11 @@ Create a new data product within a domain. ## Body Parameters - Name of the data product. Must be unique within the parent domain. + Name of the data product. Must be unique across all data products. - - Fully qualified name of the parent domain (e.g., `Marketing`). + + Fully qualified names of the parent domains, for example `["Marketing"]`. @@ -36,7 +36,7 @@ Create a new data product within a domain. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -76,24 +76,26 @@ configure( request = { "name": "CustomerInsights", "displayName": "Customer Insights", - "domain": "Marketing", + "domains": ["Marketing"], "description": "Curated customer analytics data product" } data_product = DataProducts.create(request) -print(f"Created: {data_product.fullyQualifiedName}") +print(f"Created: {data_product.fullyQualifiedName.root}") ``` ```java POST /v1/dataProducts -import static org.openmetadata.sdk.fluent.DataProducts.*; - -// Create using builder pattern -var dataProduct = DataProducts.builder() - .name("CustomerInsights") - .displayName("Customer Insights") - .domain("Marketing") - .description("Curated customer analytics data product") - .create(); +import java.util.List; +import org.openmetadata.schema.api.domains.CreateDataProduct; + +// client is an initialized OpenMetadataClient. +var request = new CreateDataProduct() + .withName("CustomerInsights") + .withDisplayName("Customer Insights") + .withDomains(List.of("Marketing")) + .withDescription("Curated customer analytics data product"); + +var dataProduct = client.dataProducts().create(request); ``` ```bash POST /v1/dataProducts @@ -102,7 +104,7 @@ curl -X POST "{base_url}/api/v1/dataProducts" \ -H "Content-Type: application/json" \ -d '{ "name": "CustomerInsights", - "domain": "Marketing", + "domains": ["Marketing"], "description": "Curated customer analytics data product", "owners": [], "experts": [] @@ -115,20 +117,22 @@ curl -X POST "{base_url}/api/v1/dataProducts" \ { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Curated customer analytics data product", "version": 0.1, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -153,7 +157,7 @@ Returns the created data product object with all specified properties and system - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. @@ -164,8 +168,8 @@ Returns the created data product object with all specified properties and system Description of the data product in Markdown format. - - Reference to the parent domain. + + References to the parent domains. @@ -224,4 +228,4 @@ curl -X PUT "{base_url}/api/v1/dataProducts" \ | `400` | `BAD_REQUEST` | Invalid request body or missing required fields | | `401` | `UNAUTHORIZED` | Invalid or missing authentication token | | `403` | `FORBIDDEN` | User lacks permission to create data products | -| `409` | `ENTITY_ALREADY_EXISTS` | Data product with same name already exists in domain (POST only) | +| `409` | `ENTITY_ALREADY_EXISTS` | Data product with the same name already exists (POST only) | diff --git a/v2.0.x/api-reference/governance/data-products/delete.mdx b/v2.0.x/api-reference/governance/data-products/delete.mdx index e69068056..eb414ec39 100644 --- a/v2.0.x/api-reference/governance/data-products/delete.mdx +++ b/v2.0.x/api-reference/governance/data-products/delete.mdx @@ -1,13 +1,13 @@ --- title: Delete a Data Product -description: Delete a data product by ID or name, with soft/hard delete options +description: Delete a data product by ID or name, permanently sidebarTitle: Delete a Data Product api: DELETE /v1/dataProducts/{id} --- # Delete a Data Product -Delete a data product by ID or fully qualified name. Supports soft delete (default), hard delete, and restore operations. +Delete a data product by ID or fully qualified name. Deleting a data product is permanent. A deleted data product can't be restored. ## Delete by ID @@ -20,7 +20,7 @@ Delete a data product by ID or fully qualified name. Supports soft delete (defau - Permanently delete the data product. If `false`, the data product is soft-deleted and can be restored. + Not needed. A deleted data product is always permanently deleted, with or without this option. ## Delete by Name @@ -28,7 +28,7 @@ Delete a data product by ID or fully qualified name. Supports soft delete (defau Use `DELETE /v1/dataProducts/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the data product (e.g., `Marketing.CustomerInsights`). + Fully qualified name of the data product, for example `CustomerInsights`. @@ -36,15 +36,7 @@ Use `DELETE /v1/dataProducts/name/{fqn}` to delete by fully qualified name. - Permanently delete the data product. - - -## Restore a Soft-Deleted Data Product - -Use `PUT /v1/dataProducts/restore` to restore a soft-deleted data product. - - - UUID of the soft-deleted data product to restore. + Not needed. A deleted data product is always permanently deleted, with or without this option. @@ -57,89 +49,53 @@ configure( jwt_token="your-jwt-token" ) -# Soft delete by ID +# Delete by ID DataProducts.delete("b1839f98-f046-5f35-bdef-20f9b3395cb2") -# Hard delete +# Delete by ID with options DataProducts.delete( "b1839f98-f046-5f35-bdef-20f9b3395cb2", hard_delete=True ) # Delete by name -DataProducts.delete_by_name("Marketing.CustomerInsights") - -# Restore a soft-deleted data product -DataProducts.restore("b1839f98-f046-5f35-bdef-20f9b3395cb2") +DataProducts.delete(DataProducts.retrieve_by_name("CustomerInsights").id) ``` ```java DELETE /v1/dataProducts/{id} -import static org.openmetadata.sdk.fluent.DataProducts.*; +import java.util.Map; -// Soft delete -DataProducts.delete("b1839f98-f046-5f35-bdef-20f9b3395cb2").execute(); +// client is an initialized OpenMetadataClient. +var id = "b1839f98-f046-5f35-bdef-20f9b3395cb2"; -// Hard delete -DataProducts.delete("b1839f98-f046-5f35-bdef-20f9b3395cb2") - .hardDelete() - .execute(); - -// Delete by name -DataProducts.deleteByName("Marketing.CustomerInsights").execute(); +// Delete (permanent) +client.dataProducts().delete(id); -// Restore -DataProducts.restore("b1839f98-f046-5f35-bdef-20f9b3395cb2"); +// Delete by name: look up the ID first +var dataProduct = client.dataProducts().getByName("CustomerInsights"); +client.dataProducts().delete(dataProduct.getId().toString()); ``` ```bash DELETE /v1/dataProducts/{id} -# Soft delete by ID +# Delete by ID curl -X DELETE "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2" \ -H "Authorization: Bearer {access_token}" -# Hard delete +# Delete with options curl -X DELETE "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2?hardDelete=true" \ -H "Authorization: Bearer {access_token}" # Delete by name -curl -X DELETE "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ +curl -X DELETE "{base_url}/api/v1/dataProducts/name/CustomerInsights" \ -H "Authorization: Bearer {access_token}" - -# Restore soft-deleted data product -curl -X PUT "{base_url}/api/v1/dataProducts/restore" \ - -H "Authorization: Bearer {access_token}" \ - -H "Content-Type: application/json" \ - -d '{"id": "b1839f98-f046-5f35-bdef-20f9b3395cb2"}' ``` - -```json Response (Soft Delete) -{ - "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", - "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", - "description": "Curated customer analytics data product", - "version": 0.2, - "updatedAt": 1769984330261, - "updatedBy": "admin", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing" - }, - "deleted": true, - "owners": [], - "experts": [] -} -``` - - --- ## Returns -Soft delete returns the data product object with `deleted: true`. Hard delete returns no content (204). Restore returns the restored data product object. +Returns `200` with no content. The data product is permanently deleted and can't be restored. --- diff --git a/v2.0.x/api-reference/governance/data-products/list.mdx b/v2.0.x/api-reference/governance/data-products/list.mdx index e0cb69de1..bc60c4adb 100644 --- a/v2.0.x/api-reference/governance/data-products/list.mdx +++ b/v2.0.x/api-reference/governance/data-products/list.mdx @@ -28,7 +28,7 @@ List all data products with optional filtering and pagination. - Comma-separated list of fields to include: `owners`, `domain`, `experts`, `assets`. See [Supported Fields](#supported-fields) below. + Comma-separated list of fields to include: `owners`, `domains`, `experts`, `assets`. See [Supported Fields](#supported-fields) below. @@ -47,44 +47,46 @@ configure( # List first page products = DataProducts.list(limit=50) -for dp in products.data: - print(f"{dp.fullyQualifiedName}") +for dp in products.entities: + print(f"{dp.fullyQualifiedName.root}") # List all with auto-pagination for dp in DataProducts.list_all(): - print(f"{dp.fullyQualifiedName}") + print(f"{dp.fullyQualifiedName.root}") # Filter by domain with fields products = DataProducts.list( - domain="Marketing", - fields=["owners", "domain", "experts", "assets"], + filters={"domain": "Marketing"}, + fields=["owners", "domains", "experts", "assets"], limit=50 ) -for dp in products.data: - print(f"{dp.fullyQualifiedName}") +for dp in products.entities: + print(f"{dp.fullyQualifiedName.root}") if dp.owners: - print(f" Owners: {[o.name for o in dp.owners]}") + print(f" Owners: {[o.name for o in dp.owners.root]}") ``` ```java GET /v1/dataProducts -import static org.openmetadata.sdk.fluent.DataProducts.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = DataProducts.list() - .limit(50) - .execute(); - -for (var dp : result.getData()) { - System.out.println(dp.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.dataProducts().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by domain with fields -var result = DataProducts.list() - .domain("Marketing") - .fields("owners", "domain", "experts", "assets") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("domain", "Marketing") + .setFields("owners,domains,experts,assets") + .setLimit(50); +var filteredPage = client.dataProducts().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/dataProducts @@ -93,7 +95,7 @@ curl "{base_url}/api/v1/dataProducts?limit=50" \ -H "Authorization: Bearer {access_token}" # Filter by domain -curl "{base_url}/api/v1/dataProducts?domain=Marketing&fields=owners,domain,experts,assets&limit=50" \ +curl "{base_url}/api/v1/dataProducts?domain=Marketing&fields=owners,domains,experts,assets&limit=50" \ -H "Authorization: Bearer {access_token}" ``` @@ -105,20 +107,22 @@ curl "{base_url}/api/v1/dataProducts?domain=Marketing&fields=owners,domain,exper { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Curated customer analytics data product", "version": 0.1, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -153,11 +157,11 @@ Returns a paginated list of data product objects. By default, only basic fields - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. - - Parent domain reference. Only included when `fields` contains `domain`. + + Parent domain references. Only included when `fields` contains `domains`. @@ -199,7 +203,7 @@ Returns a paginated list of data product objects. By default, only basic fields | Field | Description | |-------|-------------| | `owners` | Owner references (users and teams) | -| `domain` | Parent domain reference | +| `domains` | Parent domain references | | `experts` | Subject matter expert references | | `assets` | Associated data assets | diff --git a/v2.0.x/api-reference/governance/data-products/ports-assets.mdx b/v2.0.x/api-reference/governance/data-products/ports-assets.mdx index b809ceab6..c3f155b98 100644 --- a/v2.0.x/api-reference/governance/data-products/ports-assets.mdx +++ b/v2.0.x/api-reference/governance/data-products/ports-assets.mdx @@ -14,7 +14,7 @@ Manage the input ports, output ports, and associated assets of a data product. T Use `PUT /v1/dataProducts/{fqn}/assets/add` to add assets to a data product. - Fully qualified name of the data product, such as `Marketing.CustomerInsights`. + Fully qualified name of the data product, such as `CustomerInsights`. @@ -26,7 +26,7 @@ Use `PUT /v1/dataProducts/{fqn}/assets/add` to add assets to a data product. - Type of asset entity (e.g., `table`, `topic`, `dashboard`, `pipeline`). + Type of asset entity, for example `table`, `topic`, `dashboard`, `pipeline`. @@ -36,7 +36,7 @@ Use `PUT /v1/dataProducts/{fqn}/assets/add` to add assets to a data product. Use `PUT /v1/dataProducts/{fqn}/assets/remove` to remove assets from a data product. - Fully qualified name of the data product, such as `Marketing.CustomerInsights`. + Fully qualified name of the data product, such as `CustomerInsights`. @@ -48,7 +48,7 @@ Use `PUT /v1/dataProducts/{fqn}/assets/remove` to remove assets from a data prod - Type of asset entity (e.g., `table`, `topic`, `dashboard`, `pipeline`). + Type of asset entity, for example `table`, `topic`, `dashboard`, `pipeline`. @@ -64,68 +64,82 @@ configure( jwt_token="your-jwt-token" ) -# Identify the data product by its fully qualified name, and each asset by its UUID. +# Identify the data product by its name, which is also its fully qualified name, and each asset by its UUID. # Add input ports DataProducts.add_input_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-1", type="table")] ) # Remove input ports DataProducts.remove_input_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-1", type="table")] ) # Add output ports DataProducts.add_output_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="dashboard-uuid-1", type="dashboard")] ) # Remove output ports DataProducts.remove_output_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="dashboard-uuid-1", type="dashboard")] ) # Add assets DataProducts.add_assets( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-2", type="table")] ) # Remove assets DataProducts.remove_assets( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-2", type="table")] ) ``` ```java PUT /v1/dataProducts/{fqn}/assets/add -import static org.openmetadata.sdk.fluent.DataProducts.*; +import java.util.List; +import java.util.UUID; +import org.openmetadata.schema.type.EntityReference; +import org.openmetadata.schema.type.api.BulkAssets; -// Identify the data product by its fully qualified name, and each asset by its UUID. +// client is an initialized OpenMetadataClient. +var dataProduct = "CustomerInsights"; + +var tables = new BulkAssets().withAssets(List.of( + new EntityReference() + .withId(UUID.fromString("5b3d9f0e-1c7a-4d2e-9a61-3f8e2b7c4d10")) + .withType("table"))); + +// Identify the data product by its name, which is also its fully qualified name, and each asset by its UUID. // Add assets -DataProducts.addAssets( - "Marketing.CustomerInsights", - List.of(new EntityReference("table-uuid-1", "table")) -); +var added = client.dataProducts().bulkAddAssets(dataProduct, tables); +System.out.println(added.getStatus()); // Remove assets -DataProducts.removeAssets( - "Marketing.CustomerInsights", - List.of(new EntityReference("table-uuid-1", "table")) -); +var removed = client.dataProducts().bulkRemoveAssets(dataProduct, tables); + +// Add and remove input ports +client.dataProducts().bulkAddInputPorts(dataProduct, tables); +client.dataProducts().bulkRemoveInputPorts(dataProduct, tables); + +// Add and remove output ports +client.dataProducts().bulkAddOutputPorts(dataProduct, tables); +client.dataProducts().bulkRemoveOutputPorts(dataProduct, tables); ``` ```bash PUT /v1/dataProducts/{fqn}/assets/add # The path identifier is the data product's fully qualified name. URL-encode it if it contains spaces. # Add assets -curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/add" \ +curl -X PUT "{base_url}/api/v1/dataProducts/CustomerInsights/assets/add" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -136,7 +150,7 @@ curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/ad }' # Remove assets -curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/remove" \ +curl -X PUT "{base_url}/api/v1/dataProducts/CustomerInsights/assets/remove" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -152,19 +166,21 @@ curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/re { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "description": "Curated customer analytics data product", "version": 0.3, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] diff --git a/v2.0.x/api-reference/governance/data-products/retrieve.mdx b/v2.0.x/api-reference/governance/data-products/retrieve.mdx index b08cd3a49..ec3da59a5 100644 --- a/v2.0.x/api-reference/governance/data-products/retrieve.mdx +++ b/v2.0.x/api-reference/governance/data-products/retrieve.mdx @@ -16,7 +16,7 @@ Get a single data product by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,domain,experts,assets`). + Comma-separated list of fields to include, for example `owners,domains,experts,assets`. @@ -28,11 +28,11 @@ Get a single data product by its unique ID or fully qualified name. Use `GET /v1/dataProducts/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the data product (e.g., `Marketing.CustomerInsights`). + Fully qualified name of the data product, for example `CustomerInsights`. - Comma-separated list of fields to include: `owners`, `domain`, `experts`, `assets`. + Comma-separated list of fields to include: `owners`, `domains`, `experts`, `assets`. @@ -51,44 +51,40 @@ configure( # Get by ID dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2") -print(f"{dp.fullyQualifiedName}: {dp.description}") +print(f"{dp.fullyQualifiedName.root}: {getattr(dp.description, 'root', dp.description)}") # Get by ID with fields dp = DataProducts.retrieve( "b1839f98-f046-5f35-bdef-20f9b3395cb2", - fields=["owners", "domain", "experts", "assets"] + fields=["owners", "domains", "experts", "assets"] ) # Get by fully qualified name -dp = DataProducts.retrieve_by_name("Marketing.CustomerInsights") +dp = DataProducts.retrieve_by_name("CustomerInsights") # Get by name with fields dp = DataProducts.retrieve_by_name( - "Marketing.CustomerInsights", - fields=["owners", "domain", "experts", "assets"] + "CustomerInsights", + fields=["owners", "domains", "experts", "assets"] ) ``` ```java GET /v1/dataProducts/{id} -import static org.openmetadata.sdk.fluent.DataProducts.*; - -// Get by ID -var dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2"); +// client is an initialized OpenMetadataClient. +var dataProduct = client.dataProducts().get("b1839f98-f046-5f35-bdef-20f9b3395cb2"); // Get by ID with fields -var dp = DataProducts.retrieve( +var dataProductWithFields = client.dataProducts().get( "b1839f98-f046-5f35-bdef-20f9b3395cb2", - "owners,domain,experts,assets" -); + "owners,domains,experts,assets"); // Get by fully qualified name -var dp = DataProducts.retrieveByName("Marketing.CustomerInsights"); +var dataProductByName = client.dataProducts().getByName("CustomerInsights"); // Get by name with fields -var dp = DataProducts.retrieveByName( - "Marketing.CustomerInsights", - "owners,domain,experts,assets" -); +var dataProductByNameWithFields = client.dataProducts().getByName( + "CustomerInsights", + "owners,domains,experts,assets"); ``` ```bash GET /v1/dataProducts/{id} @@ -97,15 +93,15 @@ curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2" \ -H "Authorization: Bearer {access_token}" # Get by ID with fields -curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2?fields=owners,domain,experts,assets" \ +curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2?fields=owners,domains,experts,assets" \ -H "Authorization: Bearer {access_token}" # Get by fully qualified name -curl "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ +curl "{base_url}/api/v1/dataProducts/name/CustomerInsights" \ -H "Authorization: Bearer {access_token}" # Get by name with fields -curl "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights?fields=owners,domain,experts,assets" \ +curl "{base_url}/api/v1/dataProducts/name/CustomerInsights?fields=owners,domains,experts,assets" \ -H "Authorization: Bearer {access_token}" ``` @@ -115,20 +111,22 @@ curl "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights?fields=owne { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Curated customer analytics data product", "version": 0.1, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -153,7 +151,7 @@ Returns a data product object with all requested fields populated. - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. @@ -164,8 +162,8 @@ Returns a data product object with all requested fields populated. Description of the data product in Markdown format. - - Reference to the parent domain. + + References to the parent domains. diff --git a/v2.0.x/api-reference/governance/data-products/update.mdx b/v2.0.x/api-reference/governance/data-products/update.mdx index dc585f0ad..3b1f66389 100644 --- a/v2.0.x/api-reference/governance/data-products/update.mdx +++ b/v2.0.x/api-reference/governance/data-products/update.mdx @@ -20,7 +20,7 @@ Update a data product's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/dataProducts/name/{fqn}` to update by fully qualified name. - Fully qualified name of the data product (e.g., `Marketing.CustomerInsights`). + Fully qualified name of the data product, for example `CustomerInsights`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -78,16 +78,16 @@ dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2") dp.description = "Updated: Curated customer analytics with enriched profiles" updated = DataProducts.update(dp) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dataProducts/{id} -import static org.openmetadata.sdk.fluent.DataProducts.*; +// client is an initialized OpenMetadataClient. +var dataProductId = "b1839f98-f046-5f35-bdef-20f9b3395cb2"; +var dataProduct = client.dataProducts().get(dataProductId); +dataProduct.setDescription("Updated: Curated customer analytics with enriched profiles"); -// Retrieve, modify, and update -var dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2"); -dp.setDescription("Updated: Curated customer analytics with enriched profiles"); -var updated = DataProducts.update(dp); +var updated = client.dataProducts().update(dataProductId, dataProduct); ``` ```bash PATCH /v1/dataProducts/{id} @@ -100,7 +100,7 @@ curl -X PATCH "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395c ]' # Update by name -curl -X PATCH "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ +curl -X PATCH "{base_url}/api/v1/dataProducts/name/CustomerInsights" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json-patch+json" \ -d '[ @@ -114,20 +114,22 @@ curl -X PATCH "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Updated: Curated customer analytics with enriched profiles", "version": 0.2, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -152,7 +154,7 @@ Returns the updated data product object with the new version number. - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. diff --git a/v2.0.x/api-reference/governance/data-products/versions.mdx b/v2.0.x/api-reference/governance/data-products/versions.mdx index 7030bc159..e43febe9a 100644 --- a/v2.0.x/api-reference/governance/data-products/versions.mdx +++ b/v2.0.x/api-reference/governance/data-products/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dataProducts/{id}/versions/{version}` to retrieve a specific versio - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dataProducts/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import DataProducts @@ -40,31 +42,29 @@ configure( # List all versions versions = DataProducts.get_versions("b1839f98-f046-5f35-bdef-20f9b3395cb2") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version dp_v1 = DataProducts.get_specific_version( "b1839f98-f046-5f35-bdef-20f9b3395cb2", "0.1" ) -print(f"Original description: {dp_v1.description}") +print(f"Original description: {getattr(dp_v1.description, 'root', dp_v1.description)}") ``` ```java GET /v1/dataProducts/{id}/versions -import static org.openmetadata.sdk.fluent.DataProducts.*; +// client is an initialized OpenMetadataClient. +var id = "b1839f98-f046-5f35-bdef-20f9b3395cb2"; // List all versions -var history = DataProducts.getVersions("b1839f98-f046-5f35-bdef-20f9b3395cb2"); - +var history = client.dataProducts().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = DataProducts.getSpecificVersion( - "b1839f98-f046-5f35-bdef-20f9b3395cb2", - 0.1 -); +var v1 = client.dataProducts().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` @@ -84,8 +84,8 @@ curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2/versio { "entityType": "dataProduct", "versions": [ - "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"Marketing.CustomerInsights\",\"version\":0.2,\"description\":\"Updated description\"}", - "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"Marketing.CustomerInsights\",\"version\":0.1,\"description\":\"Curated customer analytics data product\"}" + "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"CustomerInsights\",\"version\":0.2,\"description\":\"Updated description\"}", + "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"CustomerInsights\",\"version\":0.1,\"description\":\"Curated customer analytics data product\"}" ] } ``` diff --git a/v2.0.x/api-reference/governance/domains/create.mdx b/v2.0.x/api-reference/governance/domains/create.mdx index f728e4c2f..7cb7f51dc 100644 --- a/v2.0.x/api-reference/governance/domains/create.mdx +++ b/v2.0.x/api-reference/governance/domains/create.mdx @@ -28,7 +28,7 @@ Create a new domain for organizing data assets by business area. - Fully qualified name of the parent domain for creating nested domains (e.g., `Engineering`). + Fully qualified name of the parent domain for creating nested domains, for example `Engineering`. @@ -40,7 +40,7 @@ Create a new domain for organizing data assets by business area. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -86,19 +86,20 @@ request = CreateDomainRequest( ) domain = Domains.create(request) -print(f"Created: {domain.fullyQualifiedName}") +print(f"Created: {domain.fullyQualifiedName.root}") ``` ```java POST /v1/domains -import static org.openmetadata.sdk.fluent.Domains.*; - -// Create using builder pattern -var domain = Domains.builder() - .name("TestDomain") - .displayName("Test Domain") - .domainType("Aggregate") - .description("Lorem ipsum...") - .create(); +import org.openmetadata.schema.api.domains.CreateDomain; + +// client is an initialized OpenMetadataClient. +var request = new CreateDomain() + .withName("TestDomain") + .withDisplayName("Test Domain") + .withDomainType(CreateDomain.DomainType.AGGREGATE) + .withDescription("Lorem ipsum..."); + +var domain = client.domains().create(request); ``` ```bash POST /v1/domains @@ -151,7 +152,7 @@ Returns the created domain object with all specified properties and system-gener - Fully qualified name (e.g., `TestDomain` or `parent.child`). + Fully qualified name, for example `TestDomain` or `parent.child`. @@ -175,7 +176,7 @@ Returns the created domain object with all specified properties and system-gener - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. diff --git a/v2.0.x/api-reference/governance/domains/delete.mdx b/v2.0.x/api-reference/governance/domains/delete.mdx index 34f12b830..0a57d3099 100644 --- a/v2.0.x/api-reference/governance/domains/delete.mdx +++ b/v2.0.x/api-reference/governance/domains/delete.mdx @@ -1,13 +1,13 @@ --- title: Delete a Domain -description: Delete a domain by ID or name, with soft/hard delete options +description: Delete a domain by ID or name, permanently sidebarTitle: Delete a Domain api: DELETE /v1/domains/{id} --- # Delete a Domain -Delete a domain by ID or fully qualified name. Supports soft delete (default), hard delete, and restore operations. +Delete a domain by ID or fully qualified name. Deleting a domain is permanent. A deleted domain can't be restored. ## Delete by ID @@ -20,7 +20,7 @@ Delete a domain by ID or fully qualified name. Supports soft delete (default), h - Permanently delete the domain. If `false`, the domain is soft-deleted and can be restored. + Not needed. A deleted domain is always permanently deleted, with or without this option. ## Delete by Name @@ -28,7 +28,7 @@ Delete a domain by ID or fully qualified name. Supports soft delete (default), h Use `DELETE /v1/domains/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the domain (e.g., `TestDomain`). + Fully qualified name of the domain, for example `TestDomain`. @@ -36,15 +36,7 @@ Use `DELETE /v1/domains/name/{fqn}` to delete by fully qualified name. - Permanently delete the domain. - - -## Restore a Soft-Deleted Domain - -Use `PUT /v1/domains/restore` to restore a soft-deleted domain. - - - UUID of the soft-deleted domain to restore. + Not needed. A deleted domain is always permanently deleted, with or without this option. @@ -57,90 +49,59 @@ configure( jwt_token="your-jwt-token" ) -# Soft delete by ID +# Delete by ID Domains.delete("a0729e98-e946-4e25-acde-10e8a2294ba1") -# Hard delete +# Delete by ID with options Domains.delete( "a0729e98-e946-4e25-acde-10e8a2294ba1", hard_delete=True ) # Delete by name -Domains.delete_by_name("TestDomain") +Domains.delete(Domains.retrieve_by_name("TestDomain").id) # Delete by name with options -Domains.delete_by_name( - "TestDomain", +Domains.delete( + Domains.retrieve_by_name("TestDomain").id, hard_delete=True ) - -# Restore a soft-deleted domain -Domains.restore("a0729e98-e946-4e25-acde-10e8a2294ba1") ``` ```java DELETE /v1/domains/{id} -import static org.openmetadata.sdk.fluent.Domains.*; +import java.util.Map; -// Soft delete -Domains.delete("a0729e98-e946-4e25-acde-10e8a2294ba1").execute(); +// client is an initialized OpenMetadataClient. +var id = "a0729e98-e946-4e25-acde-10e8a2294ba1"; -// Hard delete -Domains.delete("a0729e98-e946-4e25-acde-10e8a2294ba1") - .hardDelete() - .execute(); - -// Delete by name -Domains.deleteByName("TestDomain").execute(); +// Delete (permanent) +client.domains().delete(id); -// Restore -Domains.restore("a0729e98-e946-4e25-acde-10e8a2294ba1"); +// Delete by name: look up the ID first +var domain = client.domains().getByName("TestDomain"); +client.domains().delete(domain.getId().toString()); ``` ```bash DELETE /v1/domains/{id} -# Soft delete by ID +# Delete by ID curl -X DELETE "{base_url}/api/v1/domains/a0729e98-e946-4e25-acde-10e8a2294ba1" \ -H "Authorization: Bearer {access_token}" -# Hard delete +# Delete with options curl -X DELETE "{base_url}/api/v1/domains/a0729e98-e946-4e25-acde-10e8a2294ba1?hardDelete=true" \ -H "Authorization: Bearer {access_token}" # Delete by name curl -X DELETE "{base_url}/api/v1/domains/name/TestDomain" \ -H "Authorization: Bearer {access_token}" - -# Restore soft-deleted domain -curl -X PUT "{base_url}/api/v1/domains/restore" \ - -H "Authorization: Bearer {access_token}" \ - -H "Content-Type: application/json" \ - -d '{"id": "a0729e98-e946-4e25-acde-10e8a2294ba1"}' ``` - -```json Response (Soft Delete) -{ - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "domainType": "Aggregate", - "name": "TestDomain", - "fullyQualifiedName": "TestDomain", - "description": "Lorem ipsum...", - "version": 0.2, - "updatedAt": 1769984330261, - "updatedBy": "admin", - "deleted": true, - "owners": [], - "children": [] -} -``` - - --- ## Returns -Soft delete returns the domain object with `deleted: true`. Hard delete returns no content (204). Restore returns the restored domain object. +Returns `200` with no content. The domain is permanently deleted and can't be restored. --- diff --git a/v2.0.x/api-reference/governance/domains/list.mdx b/v2.0.x/api-reference/governance/domains/list.mdx index 6aa66ea17..19d2c1447 100644 --- a/v2.0.x/api-reference/governance/domains/list.mdx +++ b/v2.0.x/api-reference/governance/domains/list.mdx @@ -43,12 +43,12 @@ configure( # List first page domains = Domains.list(limit=50) -for d in domains.data: - print(f"{d.fullyQualifiedName} ({d.domainType})") +for d in domains.entities: + print(f"{d.fullyQualifiedName.root} ({d.domainType})") # List all with auto-pagination for d in Domains.list_all(): - print(f"{d.fullyQualifiedName}") + print(f"{d.fullyQualifiedName.root}") # With fields domains = Domains.list( @@ -56,32 +56,30 @@ domains = Domains.list( limit=50 ) -for d in domains.data: - print(f"{d.fullyQualifiedName}") +for d in domains.entities: + print(f"{d.fullyQualifiedName.root}") if d.owners: - print(f" Owners: {[o.name for o in d.owners]}") + print(f" Owners: {[o.name for o in d.owners.root]}") ``` ```java GET /v1/domains -import static org.openmetadata.sdk.fluent.Domains.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Domains.list() - .limit(50) - .execute(); - -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.domains().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // With fields -var result = Domains.list() - .fields("owners", "children", "experts") - .limit(50) - .execute(); - -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +var filtered = new ListParams() + .setFields("owners,children,experts") + .setLimit(50); +var filteredPage = client.domains().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` diff --git a/v2.0.x/api-reference/governance/domains/retrieve.mdx b/v2.0.x/api-reference/governance/domains/retrieve.mdx index 9afb82fe8..2fcbb7281 100644 --- a/v2.0.x/api-reference/governance/domains/retrieve.mdx +++ b/v2.0.x/api-reference/governance/domains/retrieve.mdx @@ -16,7 +16,7 @@ Get a single domain by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,children,experts`). + Comma-separated list of fields to include, for example `owners,children,experts`. @@ -28,7 +28,7 @@ Get a single domain by its unique ID or fully qualified name. Use `GET /v1/domains/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the domain (e.g., `TestDomain` or `Engineering.DataPlatform`). + Fully qualified name of the domain, for example `TestDomain` or `Engineering.DataPlatform`. @@ -51,7 +51,7 @@ configure( # Get by ID domain = Domains.retrieve("a0729e98-e946-4e25-acde-10e8a2294ba1") -print(f"{domain.fullyQualifiedName}: {domain.domainType}") +print(f"{domain.fullyQualifiedName.root}: {domain.domainType}") # Get by ID with fields domain = Domains.retrieve( @@ -70,22 +70,21 @@ domain = Domains.retrieve_by_name( ``` ```java GET /v1/domains/{id} -import static org.openmetadata.sdk.fluent.Domains.*; - -// Get by ID -var domain = Domains.retrieve("a0729e98-e946-4e25-acde-10e8a2294ba1"); +// client is an initialized OpenMetadataClient. +var domain = client.domains().get("a0729e98-e946-4e25-acde-10e8a2294ba1"); // Get by ID with fields -var domain = Domains.retrieve( +var domainWithFields = client.domains().get( "a0729e98-e946-4e25-acde-10e8a2294ba1", - "owners,children,experts" -); + "owners,children,experts"); // Get by fully qualified name -var domain = Domains.retrieveByName("TestDomain"); +var domainByName = client.domains().getByName("TestDomain"); // Get by name with fields -var domain = Domains.retrieveByName("TestDomain", "owners,children,experts"); +var domainByNameWithFields = client.domains().getByName( + "TestDomain", + "owners,children,experts"); ``` ```bash GET /v1/domains/{id} diff --git a/v2.0.x/api-reference/governance/domains/update.mdx b/v2.0.x/api-reference/governance/domains/update.mdx index 523e20d99..5ceb715d9 100644 --- a/v2.0.x/api-reference/governance/domains/update.mdx +++ b/v2.0.x/api-reference/governance/domains/update.mdx @@ -20,7 +20,7 @@ Update a domain's properties using JSON Merge Patch. You can update by ID or by Use `PATCH /v1/domains/name/{fqn}` to update by fully qualified name. - Fully qualified name of the domain (e.g., `TestDomain`). + Fully qualified name of the domain, for example `TestDomain`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -83,16 +83,16 @@ domain.description = "Updated domain description for business analytics" domain.domainType = "Consumer-aligned" updated = Domains.update(domain) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/domains/{id} -import static org.openmetadata.sdk.fluent.Domains.*; - -// Retrieve, modify, and update -var domain = Domains.retrieve("a0729e98-e946-4e25-acde-10e8a2294ba1"); +// client is an initialized OpenMetadataClient. +var domainId = "a0729e98-e946-4e25-acde-10e8a2294ba1"; +var domain = client.domains().get(domainId); domain.setDescription("Updated domain description for business analytics"); -var updated = Domains.update(domain); + +var updated = client.domains().update(domainId, domain); ``` ```bash PATCH /v1/domains/{id} diff --git a/v2.0.x/api-reference/governance/domains/versions.mdx b/v2.0.x/api-reference/governance/domains/versions.mdx index 9d30b534f..ccd59ec1c 100644 --- a/v2.0.x/api-reference/governance/domains/versions.mdx +++ b/v2.0.x/api-reference/governance/domains/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/domains/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/domains/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Domains @@ -40,31 +42,29 @@ configure( # List all versions versions = Domains.get_versions("a0729e98-e946-4e25-acde-10e8a2294ba1") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version domain_v1 = Domains.get_specific_version( "a0729e98-e946-4e25-acde-10e8a2294ba1", "0.1" ) -print(f"Original description: {domain_v1.description}") +print(f"Original description: {getattr(domain_v1.description, 'root', domain_v1.description)}") ``` ```java GET /v1/domains/{id}/versions -import static org.openmetadata.sdk.fluent.Domains.*; +// client is an initialized OpenMetadataClient. +var id = "a0729e98-e946-4e25-acde-10e8a2294ba1"; // List all versions -var history = Domains.getVersions("a0729e98-e946-4e25-acde-10e8a2294ba1"); - +var history = client.domains().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Domains.getSpecificVersion( - "a0729e98-e946-4e25-acde-10e8a2294ba1", - 0.1 -); +var v1 = client.domains().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/governance/glossaries/create.mdx b/v2.0.x/api-reference/governance/glossaries/create.mdx index fb0b061b0..11a8d93cc 100644 --- a/v2.0.x/api-reference/governance/glossaries/create.mdx +++ b/v2.0.x/api-reference/governance/glossaries/create.mdx @@ -32,7 +32,7 @@ Create a new glossary for organizing business terminology. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Create a new glossary for organizing business terminology. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -104,19 +104,20 @@ request = CreateGlossaryRequest( ) glossary = Glossaries.create(request) -print(f"Created: {glossary.fullyQualifiedName}") +print(f"Created: {glossary.fullyQualifiedName.root}") ``` ```java POST /v1/glossaries -import static org.openmetadata.sdk.fluent.Glossaries.*; - -// Create using builder pattern -var glossary = Glossaries.builder() - .name("BusinessGlossary") - .displayName("Business Glossary") - .description("Standard business terminology for the organization") - .mutuallyExclusive(false) - .create(); +import org.openmetadata.schema.api.data.CreateGlossary; + +// client is an initialized OpenMetadataClient. +var request = new CreateGlossary() + .withName("BusinessGlossary") + .withDisplayName("Business Glossary") + .withDescription("Standard business terminology for the organization") + .withMutuallyExclusive(false); + +var glossary = client.glossaries().create(request); ``` ```bash POST /v1/glossaries diff --git a/v2.0.x/api-reference/governance/glossaries/delete.mdx b/v2.0.x/api-reference/governance/glossaries/delete.mdx index 63176eda3..eea441b08 100644 --- a/v2.0.x/api-reference/governance/glossaries/delete.mdx +++ b/v2.0.x/api-reference/governance/glossaries/delete.mdx @@ -28,7 +28,7 @@ Delete a glossary by ID or fully qualified name. Supports soft delete (default), Use `DELETE /v1/glossaries/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the glossary (e.g., `BusinessGlossary`). + Fully qualified name of the glossary, for example `BusinessGlossary`. @@ -67,28 +67,30 @@ Glossaries.delete( ) # Delete by name -Glossaries.delete_by_name("BusinessGlossary") +Glossaries.delete(Glossaries.retrieve_by_name("BusinessGlossary").id) # Restore a soft-deleted glossary Glossaries.restore("c2940a98-f147-6g46-cdef-31f0c4406dc3") ``` ```java DELETE /v1/glossaries/{id} -import static org.openmetadata.sdk.fluent.Glossaries.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "c2940a98-f147-6g46-cdef-31f0c4406dc3"; // Soft delete -Glossaries.delete("c2940a98-f147-6g46-cdef-31f0c4406dc3").execute(); +client.glossaries().delete(id); -// Hard delete -Glossaries.delete("c2940a98-f147-6g46-cdef-31f0c4406dc3") - .hardDelete() - .execute(); +// Restore +client.glossaries().restore(id); -// Delete by name -Glossaries.deleteByName("BusinessGlossary").execute(); +// Hard delete +client.glossaries().delete(id, Map.of("hardDelete", "true")); -// Restore -Glossaries.restore("c2940a98-f147-6g46-cdef-31f0c4406dc3"); +// Delete by name: look up the ID first +var glossary = client.glossaries().getByName("BusinessGlossary"); +client.glossaries().delete(glossary.getId().toString()); ``` ```bash DELETE /v1/glossaries/{id} diff --git a/v2.0.x/api-reference/governance/glossaries/list.mdx b/v2.0.x/api-reference/governance/glossaries/list.mdx index f22003d70..29fa57f6c 100644 --- a/v2.0.x/api-reference/governance/glossaries/list.mdx +++ b/v2.0.x/api-reference/governance/glossaries/list.mdx @@ -43,12 +43,12 @@ configure( # List first page glossaries = Glossaries.list(limit=50) -for g in glossaries.data: - print(f"{g.fullyQualifiedName}") +for g in glossaries.entities: + print(f"{g.fullyQualifiedName.root}") # List all with auto-pagination for g in Glossaries.list_all(): - print(f"{g.fullyQualifiedName}") + print(f"{g.fullyQualifiedName.root}") # With fields glossaries = Glossaries.list( @@ -56,29 +56,31 @@ glossaries = Glossaries.list( limit=50 ) -for g in glossaries.data: - print(f"{g.fullyQualifiedName}") +for g in glossaries.entities: + print(f"{g.fullyQualifiedName.root}") if g.reviewers: print(f" Reviewers: {[r.name for r in g.reviewers]}") ``` ```java GET /v1/glossaries -import static org.openmetadata.sdk.fluent.Glossaries.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Glossaries.list() - .limit(50) - .execute(); - -for (var g : result.getData()) { - System.out.println(g.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.glossaries().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // With fields -var result = Glossaries.list() - .fields("owners", "tags", "reviewers") - .limit(50) - .execute(); +var filtered = new ListParams() + .setFields("owners,tags,reviewers") + .setLimit(50); +var filteredPage = client.glossaries().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/glossaries diff --git a/v2.0.x/api-reference/governance/glossaries/retrieve.mdx b/v2.0.x/api-reference/governance/glossaries/retrieve.mdx index 363d22fdd..275ed83fa 100644 --- a/v2.0.x/api-reference/governance/glossaries/retrieve.mdx +++ b/v2.0.x/api-reference/governance/glossaries/retrieve.mdx @@ -16,7 +16,7 @@ Get a single glossary by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains,reviewers`). + Comma-separated list of fields to include, for example `owners,tags,domains,reviewers`. @@ -28,7 +28,7 @@ Get a single glossary by its unique ID or fully qualified name. Use `GET /v1/glossaries/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the glossary (e.g., `BusinessGlossary`). + Fully qualified name of the glossary, for example `BusinessGlossary`. @@ -51,7 +51,7 @@ configure( # Get by ID glossary = Glossaries.retrieve("c2940a98-f147-6g46-cdef-31f0c4406dc3") -print(f"{glossary.fullyQualifiedName}: {glossary.description}") +print(f"{glossary.fullyQualifiedName.root}: {getattr(glossary.description, 'root', glossary.description)}") # Get by ID with fields glossary = Glossaries.retrieve( @@ -70,22 +70,21 @@ glossary = Glossaries.retrieve_by_name( ``` ```java GET /v1/glossaries/{id} -import static org.openmetadata.sdk.fluent.Glossaries.*; - -// Get by ID -var glossary = Glossaries.retrieve("c2940a98-f147-6g46-cdef-31f0c4406dc3"); +// client is an initialized OpenMetadataClient. +var glossary = client.glossaries().get("c2940a98-f147-6g46-cdef-31f0c4406dc3"); // Get by ID with fields -var glossary = Glossaries.retrieve( +var glossaryWithFields = client.glossaries().get( "c2940a98-f147-6g46-cdef-31f0c4406dc3", - "owners,tags,reviewers" -); + "owners,tags,reviewers"); // Get by fully qualified name -var glossary = Glossaries.retrieveByName("BusinessGlossary"); +var glossaryByName = client.glossaries().getByName("BusinessGlossary"); // Get by name with fields -var glossary = Glossaries.retrieveByName("BusinessGlossary", "owners,tags,reviewers"); +var glossaryByNameWithFields = client.glossaries().getByName( + "BusinessGlossary", + "owners,tags,reviewers"); ``` ```bash GET /v1/glossaries/{id} diff --git a/v2.0.x/api-reference/governance/glossaries/update.mdx b/v2.0.x/api-reference/governance/glossaries/update.mdx index 8bcb58598..9fb29ea9b 100644 --- a/v2.0.x/api-reference/governance/glossaries/update.mdx +++ b/v2.0.x/api-reference/governance/glossaries/update.mdx @@ -20,7 +20,7 @@ Update a glossary's properties using JSON Merge Patch. You can update by ID or b Use `PATCH /v1/glossaries/name/{fqn}` to update by fully qualified name. - Fully qualified name of the glossary (e.g., `BusinessGlossary`). + Fully qualified name of the glossary, for example `BusinessGlossary`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -76,17 +76,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -105,16 +105,16 @@ glossary.description = "Updated: Comprehensive business terminology dictionary" glossary.mutuallyExclusive = True updated = Glossaries.update(glossary) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/glossaries/{id} -import static org.openmetadata.sdk.fluent.Glossaries.*; - -// Retrieve, modify, and update -var glossary = Glossaries.retrieve("c2940a98-f147-6g46-cdef-31f0c4406dc3"); +// client is an initialized OpenMetadataClient. +var glossaryId = "c2940a98-f147-6g46-cdef-31f0c4406dc3"; +var glossary = client.glossaries().get(glossaryId); glossary.setDescription("Updated: Comprehensive business terminology dictionary"); -var updated = Glossaries.update(glossary); + +var updated = client.glossaries().update(glossaryId, glossary); ``` ```bash PATCH /v1/glossaries/{id} diff --git a/v2.0.x/api-reference/governance/glossaries/versions.mdx b/v2.0.x/api-reference/governance/glossaries/versions.mdx index 979d53ed4..8ee8acd38 100644 --- a/v2.0.x/api-reference/governance/glossaries/versions.mdx +++ b/v2.0.x/api-reference/governance/glossaries/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/glossaries/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/glossaries/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Glossaries @@ -40,31 +42,29 @@ configure( # List all versions versions = Glossaries.get_versions("c2940a98-f147-6g46-cdef-31f0c4406dc3") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version glossary_v1 = Glossaries.get_specific_version( "c2940a98-f147-6g46-cdef-31f0c4406dc3", "0.1" ) -print(f"Original description: {glossary_v1.description}") +print(f"Original description: {getattr(glossary_v1.description, 'root', glossary_v1.description)}") ``` ```java GET /v1/glossaries/{id}/versions -import static org.openmetadata.sdk.fluent.Glossaries.*; +// client is an initialized OpenMetadataClient. +var id = "c2940a98-f147-6g46-cdef-31f0c4406dc3"; // List all versions -var history = Glossaries.getVersions("c2940a98-f147-6g46-cdef-31f0c4406dc3"); - +var history = client.glossaries().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Glossaries.getSpecificVersion( - "c2940a98-f147-6g46-cdef-31f0c4406dc3", - 0.1 -); +var v1 = client.glossaries().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/governance/glossary-terms/create.mdx b/v2.0.x/api-reference/governance/glossary-terms/create.mdx index dc3fc9f08..65e05d992 100644 --- a/v2.0.x/api-reference/governance/glossary-terms/create.mdx +++ b/v2.0.x/api-reference/governance/glossary-terms/create.mdx @@ -16,7 +16,7 @@ Create a new glossary term within a glossary. - Fully qualified name of the parent glossary (e.g., `BusinessGlossary`). + Fully qualified name of the parent glossary, for example `BusinessGlossary`. @@ -28,7 +28,7 @@ Create a new glossary term within a glossary. - Fully qualified name of the parent glossary term for creating nested terms (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the parent glossary term for creating nested terms, for example `BusinessGlossary.Revenue`. @@ -48,7 +48,7 @@ Create a new glossary term within a glossary. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,17 +66,17 @@ Create a new glossary term within a glossary. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -84,7 +84,7 @@ Create a new glossary term within a glossary. - Hex color code (e.g., `#FF5733`). + Hex color code, for example `#FF5733`. @@ -113,20 +113,22 @@ request = CreateGlossaryTermRequest( ) term = GlossaryTerms.create(request) -print(f"Created: {term.fullyQualifiedName}") +print(f"Created: {term.fullyQualifiedName.root}") ``` ```java POST /v1/glossaryTerms -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; - -// Create using builder pattern -var term = GlossaryTerms.builder() - .name("Revenue") - .glossary("BusinessGlossary") - .displayName("Revenue") - .description("Total income generated from business operations") - .synonyms(List.of("Income", "Earnings", "Sales")) - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateGlossaryTerm; + +// client is an initialized OpenMetadataClient. +var request = new CreateGlossaryTerm() + .withName("Revenue") + .withGlossary("BusinessGlossary") + .withDisplayName("Revenue") + .withDescription("Total income generated from business operations") + .withSynonyms(List.of("Income", "Earnings", "Sales")); + +var term = client.glossaryTerms().create(request); ``` ```bash POST /v1/glossaryTerms diff --git a/v2.0.x/api-reference/governance/glossary-terms/delete.mdx b/v2.0.x/api-reference/governance/glossary-terms/delete.mdx index 59cee26b5..885fa95ea 100644 --- a/v2.0.x/api-reference/governance/glossary-terms/delete.mdx +++ b/v2.0.x/api-reference/governance/glossary-terms/delete.mdx @@ -28,7 +28,7 @@ Delete a glossary term by ID or fully qualified name. Supports soft delete (defa Use `DELETE /v1/glossaryTerms/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the glossary term (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the glossary term, for example `BusinessGlossary.Revenue`. @@ -67,28 +67,30 @@ GlossaryTerms.delete( ) # Delete by name -GlossaryTerms.delete_by_name("BusinessGlossary.Revenue") +GlossaryTerms.delete(GlossaryTerms.retrieve_by_name("BusinessGlossary.Revenue").id) # Restore a soft-deleted glossary term GlossaryTerms.restore("d3a50b09-g258-7h57-defg-42g1d5517ed4") ``` ```java DELETE /v1/glossaryTerms/{id} -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "d3a50b09-g258-7h57-defg-42g1d5517ed4"; // Soft delete -GlossaryTerms.delete("d3a50b09-g258-7h57-defg-42g1d5517ed4").execute(); +client.glossaryTerms().delete(id); -// Hard delete -GlossaryTerms.delete("d3a50b09-g258-7h57-defg-42g1d5517ed4") - .hardDelete() - .execute(); +// Restore +client.glossaryTerms().restore(id); -// Delete by name -GlossaryTerms.deleteByName("BusinessGlossary.Revenue").execute(); +// Hard delete +client.glossaryTerms().delete(id, Map.of("hardDelete", "true")); -// Restore -GlossaryTerms.restore("d3a50b09-g258-7h57-defg-42g1d5517ed4"); +// Delete by name: look up the ID first +var term = client.glossaryTerms().getByName("BusinessGlossary.Revenue"); +client.glossaryTerms().delete(term.getId().toString()); ``` ```bash DELETE /v1/glossaryTerms/{id} diff --git a/v2.0.x/api-reference/governance/glossary-terms/list.mdx b/v2.0.x/api-reference/governance/glossary-terms/list.mdx index b51449643..344253bd2 100644 --- a/v2.0.x/api-reference/governance/glossary-terms/list.mdx +++ b/v2.0.x/api-reference/governance/glossary-terms/list.mdx @@ -60,7 +60,7 @@ GET /api/v1/glossaryTerms?directChildrenOf=BusinessGlossary.Revenue&limit=1000 ```python GET /v1/glossaryTerms from metadata.sdk import configure -from metadata.sdk.entities import GlossaryTerms +from metadata.sdk.entities import Glossaries, GlossaryTerms configure( host="https://your-company.open-metadata.org/api", @@ -69,44 +69,47 @@ configure( # List first page terms = GlossaryTerms.list(limit=50) -for t in terms.data: - print(f"{t.fullyQualifiedName}") +for t in terms.entities: + print(f"{t.fullyQualifiedName.root}") # List all with auto-pagination for t in GlossaryTerms.list_all(): - print(f"{t.fullyQualifiedName}") + print(f"{t.fullyQualifiedName.root}") # Filter by glossary with fields +glossary = Glossaries.retrieve_by_name("BusinessGlossary") terms = GlossaryTerms.list( - glossary="c2940a98-f147-4a46-8def-31f0c4406dc3", # glossary ID (UUID) + filters={"glossary": str(glossary.id.root)}, fields=["owners", "tags", "relatedTerms", "children"], limit=50 ) -for t in terms.data: - print(f"{t.fullyQualifiedName}") +for t in terms.entities: + print(f"{t.fullyQualifiedName.root}") if t.synonyms: print(f" Synonyms: {t.synonyms}") ``` ```java GET /v1/glossaryTerms -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = GlossaryTerms.list() - .limit(50) - .execute(); - -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.glossaryTerms().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by glossary with fields -var result = GlossaryTerms.list() - .glossary("c2940a98-f147-4a46-8def-31f0c4406dc3") - .fields("owners", "tags", "relatedTerms", "children") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("glossary", "c2940a98-f147-4a46-8def-31f0c4406dc3") + .setFields("owners,tags,relatedTerms,children") + .setLimit(50); +var filteredPage = client.glossaryTerms().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/glossaryTerms diff --git a/v2.0.x/api-reference/governance/glossary-terms/retrieve.mdx b/v2.0.x/api-reference/governance/glossary-terms/retrieve.mdx index 0bdf84ae2..d55d668ba 100644 --- a/v2.0.x/api-reference/governance/glossary-terms/retrieve.mdx +++ b/v2.0.x/api-reference/governance/glossary-terms/retrieve.mdx @@ -16,7 +16,7 @@ Get a single glossary term by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains,relatedTerms,reviewers,children`). + Comma-separated list of fields to include, for example `owners,tags,domains,relatedTerms,reviewers,children`. @@ -28,7 +28,7 @@ Get a single glossary term by its unique ID or fully qualified name. Use `GET /v1/glossaryTerms/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the glossary term (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the glossary term, for example `BusinessGlossary.Revenue`. @@ -51,7 +51,7 @@ configure( # Get by ID term = GlossaryTerms.retrieve("d3a50b09-g258-7h57-defg-42g1d5517ed4") -print(f"{term.fullyQualifiedName}: {term.description}") +print(f"{term.fullyQualifiedName.root}: {getattr(term.description, 'root', term.description)}") # Get by ID with fields term = GlossaryTerms.retrieve( @@ -70,25 +70,21 @@ term = GlossaryTerms.retrieve_by_name( ``` ```java GET /v1/glossaryTerms/{id} -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; - -// Get by ID -var term = GlossaryTerms.retrieve("d3a50b09-g258-7h57-defg-42g1d5517ed4"); +// client is an initialized OpenMetadataClient. +var term = client.glossaryTerms().get("d3a50b09-g258-7h57-defg-42g1d5517ed4"); // Get by ID with fields -var term = GlossaryTerms.retrieve( +var termWithFields = client.glossaryTerms().get( "d3a50b09-g258-7h57-defg-42g1d5517ed4", - "owners,tags,relatedTerms,children" -); + "owners,tags,relatedTerms,children"); // Get by fully qualified name -var term = GlossaryTerms.retrieveByName("BusinessGlossary.Revenue"); +var termByName = client.glossaryTerms().getByName("BusinessGlossary.Revenue"); // Get by name with fields -var term = GlossaryTerms.retrieveByName( +var termByNameWithFields = client.glossaryTerms().getByName( "BusinessGlossary.Revenue", - "owners,tags,relatedTerms,children" -); + "owners,tags,relatedTerms,children"); ``` ```bash GET /v1/glossaryTerms/{id} diff --git a/v2.0.x/api-reference/governance/glossary-terms/update.mdx b/v2.0.x/api-reference/governance/glossary-terms/update.mdx index f581f5509..9992e9a93 100644 --- a/v2.0.x/api-reference/governance/glossary-terms/update.mdx +++ b/v2.0.x/api-reference/governance/glossary-terms/update.mdx @@ -20,7 +20,7 @@ Update a glossary term's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/glossaryTerms/name/{fqn}` to update by fully qualified name. - Fully qualified name of the glossary term (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the glossary term, for example `BusinessGlossary.Revenue`. ## Body Parameters @@ -52,7 +52,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,11 +66,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -80,7 +80,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Hex color code (e.g., `#FF5733`). + Hex color code, for example `#FF5733`. @@ -89,8 +89,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -109,16 +109,16 @@ term.description = "Updated: Total income from all business operations before de term.synonyms = ["Income", "Earnings", "Sales", "Turnover"] updated = GlossaryTerms.update(term) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/glossaryTerms/{id} -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; - -// Retrieve, modify, and update -var term = GlossaryTerms.retrieve("d3a50b09-g258-7h57-defg-42g1d5517ed4"); +// client is an initialized OpenMetadataClient. +var termId = "d3a50b09-g258-7h57-defg-42g1d5517ed4"; +var term = client.glossaryTerms().get(termId); term.setDescription("Updated: Total income from all business operations before deductions"); -var updated = GlossaryTerms.update(term); + +var updated = client.glossaryTerms().update(termId, term); ``` ```bash PATCH /v1/glossaryTerms/{id} diff --git a/v2.0.x/api-reference/governance/glossary-terms/versions.mdx b/v2.0.x/api-reference/governance/glossary-terms/versions.mdx index b64c53bf9..16998a3d8 100644 --- a/v2.0.x/api-reference/governance/glossary-terms/versions.mdx +++ b/v2.0.x/api-reference/governance/glossary-terms/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/glossaryTerms/{id}/versions/{version}` to retrieve a specific versi - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/glossaryTerms/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import GlossaryTerms @@ -40,31 +42,29 @@ configure( # List all versions versions = GlossaryTerms.get_versions("d3a50b09-g258-7h57-defg-42g1d5517ed4") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version term_v1 = GlossaryTerms.get_specific_version( "d3a50b09-g258-7h57-defg-42g1d5517ed4", "0.1" ) -print(f"Original description: {term_v1.description}") +print(f"Original description: {getattr(term_v1.description, 'root', term_v1.description)}") ``` ```java GET /v1/glossaryTerms/{id}/versions -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; +// client is an initialized OpenMetadataClient. +var id = "d3a50b09-g258-7h57-defg-42g1d5517ed4"; // List all versions -var history = GlossaryTerms.getVersions("d3a50b09-g258-7h57-defg-42g1d5517ed4"); - +var history = client.glossaryTerms().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = GlossaryTerms.getSpecificVersion( - "d3a50b09-g258-7h57-defg-42g1d5517ed4", - 0.1 -); +var v1 = client.glossaryTerms().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/governance/metrics/create.mdx b/v2.0.x/api-reference/governance/metrics/create.mdx index ef91bca16..34250d6a2 100644 --- a/v2.0.x/api-reference/governance/metrics/create.mdx +++ b/v2.0.x/api-reference/governance/metrics/create.mdx @@ -169,7 +169,7 @@ request = CreateMetricRequest( ) metric = Metrics.create(request) -print(f"Created: {metric.fullyQualifiedName}") +print(f"Created: {metric.fullyQualifiedName.root}") ``` ```java POST /v1/metrics diff --git a/v2.0.x/api-reference/governance/metrics/list.mdx b/v2.0.x/api-reference/governance/metrics/list.mdx index 0c548208c..5589757ec 100644 --- a/v2.0.x/api-reference/governance/metrics/list.mdx +++ b/v2.0.x/api-reference/governance/metrics/list.mdx @@ -48,7 +48,7 @@ page = Metrics.list( ) for metric in page.entities: - print(f"{metric.fullyQualifiedName}: {metric.metricType}") + print(f"{metric.fullyQualifiedName.root}: {metric.metricType}") # Fetch every metric using automatic cursor pagination. for metric in Metrics.list_all(batch_size=100): diff --git a/v2.0.x/api-reference/governance/metrics/retrieve.mdx b/v2.0.x/api-reference/governance/metrics/retrieve.mdx index f66931029..d9563760b 100644 --- a/v2.0.x/api-reference/governance/metrics/retrieve.mdx +++ b/v2.0.x/api-reference/governance/metrics/retrieve.mdx @@ -49,7 +49,7 @@ configure( # Get by ID. metric = Metrics.retrieve("b8a9d6e4-2f7c-4f3a-9c1e-6d5b8a7f2e10") -print(f"{metric.fullyQualifiedName}: {metric.displayName}") +print(f"{metric.fullyQualifiedName.root}: {metric.displayName}") # Get by ID with relationship fields. metric = Metrics.retrieve( diff --git a/v2.0.x/api-reference/governance/metrics/update.mdx b/v2.0.x/api-reference/governance/metrics/update.mdx index 20427db3a..b9e126e63 100644 --- a/v2.0.x/api-reference/governance/metrics/update.mdx +++ b/v2.0.x/api-reference/governance/metrics/update.mdx @@ -55,7 +55,7 @@ metric.description = "Percentage of active customers retained month over month." metric.displayName = "Monthly Customer Retention Rate" updated = Metrics.update(metric) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/metrics/{id} diff --git a/v2.0.x/api-reference/governance/tags/create.mdx b/v2.0.x/api-reference/governance/tags/create.mdx index 729d1ff42..d6be682af 100644 --- a/v2.0.x/api-reference/governance/tags/create.mdx +++ b/v2.0.x/api-reference/governance/tags/create.mdx @@ -16,7 +16,7 @@ Create a new tag within a classification. - Fully qualified name of the parent classification (e.g., `Certification`). + Fully qualified name of the parent classification, for example `Certification`. @@ -28,7 +28,7 @@ Create a new tag within a classification. - Fully qualified name of the parent tag for creating nested tags (e.g., `PII.Sensitive`). + Fully qualified name of the parent tag for creating nested tags, for example `PII.Sensitive`. @@ -36,7 +36,7 @@ Create a new tag within a classification. - Hex color code (e.g., `#C08320`). + Hex color code, for example `#C08320`. @@ -54,7 +54,7 @@ Create a new tag within a classification. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -86,19 +86,21 @@ request = CreateTagRequest( ) tag = Tags.create(request) -print(f"Created: {tag.fullyQualifiedName}") +print(f"Created: {tag.fullyQualifiedName.root}") ``` ```java POST /v1/tags -import static org.openmetadata.sdk.fluent.Tags.*; - -// Create using builder pattern -var tag = Tags.builder() - .name("Bronze") - .classification("Certification") - .description("Bronze certified Data Asset.") - .style(Map.of("color", "#C08320")) - .create(); +import org.openmetadata.schema.api.classification.CreateTag; +import org.openmetadata.schema.entity.type.Style; + +// client is an initialized OpenMetadataClient. +var request = new CreateTag() + .withName("Bronze") + .withClassification("Certification") + .withDescription("Bronze certified Data Asset.") + .withStyle(new Style().withColor("#C08320")); + +var tag = client.tags().create(request); ``` ```bash POST /v1/tags diff --git a/v2.0.x/api-reference/governance/tags/delete.mdx b/v2.0.x/api-reference/governance/tags/delete.mdx index 9bcc64a75..833580aee 100644 --- a/v2.0.x/api-reference/governance/tags/delete.mdx +++ b/v2.0.x/api-reference/governance/tags/delete.mdx @@ -28,7 +28,7 @@ Delete a tag by ID or fully qualified name. Supports soft delete (default), hard Use `DELETE /v1/tags/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the tag (e.g., `Certification.Bronze`). + Fully qualified name of the tag, for example `Certification.Bronze`. @@ -67,28 +67,30 @@ Tags.delete( ) # Delete by name -Tags.delete_by_name("Certification.Bronze") +Tags.delete(Tags.retrieve_by_name("Certification.Bronze").id) # Restore a soft-deleted tag Tags.restore("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") ``` ```java DELETE /v1/tags/{id} -import static org.openmetadata.sdk.fluent.Tags.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "68ec158c-5f5e-4277-8a19-5e9e0cd5294f"; // Soft delete -Tags.delete("68ec158c-5f5e-4277-8a19-5e9e0cd5294f").execute(); +client.tags().delete(id); -// Hard delete -Tags.delete("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") - .hardDelete() - .execute(); +// Restore +client.tags().restore(id); -// Delete by name -Tags.deleteByName("Certification.Bronze").execute(); +// Hard delete +client.tags().delete(id, Map.of("hardDelete", "true")); -// Restore -Tags.restore("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); +// Delete by name: look up the ID first +var tag = client.tags().getByName("Certification.Bronze"); +client.tags().delete(tag.getId().toString()); ``` ```bash DELETE /v1/tags/{id} diff --git a/v2.0.x/api-reference/governance/tags/list.mdx b/v2.0.x/api-reference/governance/tags/list.mdx index dfb16c47e..02efdd34f 100644 --- a/v2.0.x/api-reference/governance/tags/list.mdx +++ b/v2.0.x/api-reference/governance/tags/list.mdx @@ -12,7 +12,7 @@ List all tags with optional filtering and pagination. ## Query Parameters - Filter by parent classification fully qualified name (e.g., `Certification`). + Filter by parent classification fully qualified name, for example `Certification`. @@ -47,44 +47,46 @@ configure( # List first page tags = Tags.list(limit=50) -for t in tags.data: - print(f"{t.fullyQualifiedName}") +for t in tags.entities: + print(f"{t.fullyQualifiedName.root}") # List all with auto-pagination for t in Tags.list_all(): - print(f"{t.fullyQualifiedName}") + print(f"{t.fullyQualifiedName.root}") # Filter by classification tags = Tags.list( - parent="Certification", + filters={"parent": "Certification"}, fields=["owners", "children"], limit=50 ) -for t in tags.data: - print(f"{t.fullyQualifiedName}") +for t in tags.entities: + print(f"{t.fullyQualifiedName.root}") if t.style: - print(f" Color: {t.style.get('color')}") + print(f" Color: {t.style.color}") ``` ```java GET /v1/tags -import static org.openmetadata.sdk.fluent.Tags.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Tags.list() - .limit(50) - .execute(); - -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.tags().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by classification with fields -var result = Tags.list() - .parent("Certification") - .fields("owners", "children") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("parent", "Certification") + .setFields("owners,children") + .setLimit(50); +var filteredPage = client.tags().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/tags diff --git a/v2.0.x/api-reference/governance/tags/retrieve.mdx b/v2.0.x/api-reference/governance/tags/retrieve.mdx index d6a5cf81e..7bcc4709c 100644 --- a/v2.0.x/api-reference/governance/tags/retrieve.mdx +++ b/v2.0.x/api-reference/governance/tags/retrieve.mdx @@ -16,7 +16,7 @@ Get a single tag by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,children`). + Comma-separated list of fields to include, for example `owners,children`. @@ -28,7 +28,7 @@ Get a single tag by its unique ID or fully qualified name. Use `GET /v1/tags/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the tag (e.g., `Certification.Bronze`). + Fully qualified name of the tag, for example `Certification.Bronze`. @@ -51,7 +51,7 @@ configure( # Get by ID tag = Tags.retrieve("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") -print(f"{tag.fullyQualifiedName}: {tag.description}") +print(f"{tag.fullyQualifiedName.root}: {getattr(tag.description, 'root', tag.description)}") # Get by ID with fields tag = Tags.retrieve( @@ -70,22 +70,21 @@ tag = Tags.retrieve_by_name( ``` ```java GET /v1/tags/{id} -import static org.openmetadata.sdk.fluent.Tags.*; - -// Get by ID -var tag = Tags.retrieve("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); +// client is an initialized OpenMetadataClient. +var tag = client.tags().get("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); // Get by ID with fields -var tag = Tags.retrieve( +var tagWithFields = client.tags().get( "68ec158c-5f5e-4277-8a19-5e9e0cd5294f", - "owners,children" -); + "owners,children"); // Get by fully qualified name -var tag = Tags.retrieveByName("Certification.Bronze"); +var tagByName = client.tags().getByName("Certification.Bronze"); // Get by name with fields -var tag = Tags.retrieveByName("Certification.Bronze", "owners,children"); +var tagByNameWithFields = client.tags().getByName( + "Certification.Bronze", + "owners,children"); ``` ```bash GET /v1/tags/{id} diff --git a/v2.0.x/api-reference/governance/tags/update.mdx b/v2.0.x/api-reference/governance/tags/update.mdx index 68105a8b8..2a4131dc6 100644 --- a/v2.0.x/api-reference/governance/tags/update.mdx +++ b/v2.0.x/api-reference/governance/tags/update.mdx @@ -20,7 +20,7 @@ Update a tag's properties using JSON Merge Patch. You can update by ID or by ful Use `PATCH /v1/tags/name/{fqn}` to update by fully qualified name. - Fully qualified name of the tag (e.g., `Certification.Bronze`). + Fully qualified name of the tag, for example `Certification.Bronze`. ## Body Parameters @@ -40,7 +40,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Hex color code (e.g., `#C08320`). + Hex color code, for example `#C08320`. @@ -58,7 +58,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -79,16 +79,16 @@ tag.description = "Updated: Bronze level certification for data assets" tag.style = {"color": "#D4A017"} updated = Tags.update(tag) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/tags/{id} -import static org.openmetadata.sdk.fluent.Tags.*; - -// Retrieve, modify, and update -var tag = Tags.retrieve("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); +// client is an initialized OpenMetadataClient. +var tagId = "68ec158c-5f5e-4277-8a19-5e9e0cd5294f"; +var tag = client.tags().get(tagId); tag.setDescription("Updated: Bronze level certification for data assets"); -var updated = Tags.update(tag); + +var updated = client.tags().update(tagId, tag); ``` ```bash PATCH /v1/tags/{id} diff --git a/v2.0.x/api-reference/governance/tags/versions.mdx b/v2.0.x/api-reference/governance/tags/versions.mdx index 3b7fbfaa0..63a5e4474 100644 --- a/v2.0.x/api-reference/governance/tags/versions.mdx +++ b/v2.0.x/api-reference/governance/tags/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/tags/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/tags/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Tags @@ -40,31 +42,29 @@ configure( # List all versions versions = Tags.get_versions("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version tag_v1 = Tags.get_specific_version( "68ec158c-5f5e-4277-8a19-5e9e0cd5294f", "0.1" ) -print(f"Original description: {tag_v1.description}") +print(f"Original description: {getattr(tag_v1.description, 'root', tag_v1.description)}") ``` ```java GET /v1/tags/{id}/versions -import static org.openmetadata.sdk.fluent.Tags.*; +// client is an initialized OpenMetadataClient. +var id = "68ec158c-5f5e-4277-8a19-5e9e0cd5294f"; // List all versions -var history = Tags.getVersions("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); - +var history = client.tags().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Tags.getSpecificVersion( - "68ec158c-5f5e-4277-8a19-5e9e0cd5294f", - 0.1 -); +var v1 = client.tags().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.0.x/api-reference/lineage/export.mdx b/v2.0.x/api-reference/lineage/export.mdx index 0c9822e2d..ca38ffdca 100644 --- a/v2.0.x/api-reference/lineage/export.mdx +++ b/v2.0.x/api-reference/lineage/export.mdx @@ -12,7 +12,7 @@ Export the lineage graph for a given entity as a CSV file. Useful for auditing, ## Query Parameters - Fully qualified name of the entity to export lineage for (e.g., `sample_data.ecommerce_db.shopify.dim_customer`). + Fully qualified name of the entity to export lineage for, for example `sample_data.ecommerce_db.shopify.dim_customer`. @@ -29,21 +29,24 @@ Export the lineage graph for a given entity as a CSV file. Useful for auditing, ```python GET /v1/lineage/export -from metadata.sdk import configure, get_client +from urllib.parse import urlencode + +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Export lineage as CSV -response = client.get("/lineage/export", params={ +params = urlencode({ "fqn": "sample_data.ecommerce_db.shopify.dim_customer", "type": "table", "upstreamDepth": 3, "downstreamDepth": 2, }) +response = rest.get(f"/lineage/export?{params}") print(response.text) ``` diff --git a/v2.0.x/api-reference/pagination.mdx b/v2.0.x/api-reference/pagination.mdx index 4e85649d9..468a950c4 100644 --- a/v2.0.x/api-reference/pagination.mdx +++ b/v2.0.x/api-reference/pagination.mdx @@ -95,25 +95,23 @@ if first_page.paging.after: ``` ```java Basic Pagination -import org.openmetadata.client.api.TablesApi; -import org.openmetadata.client.model.TableList; +import org.openmetadata.sdk.models.ListParams; -TablesApi tablesApi = client.buildClient(TablesApi.class); +// client is an initialized OpenMetadataClient. // Get first page -TableList firstPage = tablesApi.listTables(null, 20, null, null, null); +var firstPage = client.tables().list(new ListParams().setLimit(20)); System.out.println("Total tables: " + firstPage.getPaging().getTotal()); -for (Table table : firstPage.getData()) { +for (var table : firstPage.getData()) { System.out.println(table.getFullyQualifiedName()); } // Get next page if (firstPage.getPaging().getAfter() != null) { - TableList nextPage = tablesApi.listTables( - null, 20, null, firstPage.getPaging().getAfter(), null - ); - for (Table table : nextPage.getData()) { + var nextPage = client.tables().list( + new ListParams().setLimit(20).setAfter(firstPage.getPaging().getAfter())); + for (var table : nextPage.getData()) { System.out.println(table.getFullyQualifiedName()); } } @@ -171,15 +169,20 @@ for table in metadata.list_all_entities(entity=Table, limit=100): ``` ```java Iterating Results -import org.openmetadata.client.api.TablesApi; +import org.openmetadata.sdk.models.ListParams; + +// client is an initialized OpenMetadataClient. -TablesApi tablesApi = client.buildClient(TablesApi.class); String afterCursor = null; do { - TableList page = tablesApi.listTables(null, 100, null, afterCursor, null); + var params = new ListParams().setLimit(100); + if (afterCursor != null) { + params.setAfter(afterCursor); + } + var page = client.tables().list(params); - for (Table table : page.getData()) { + for (var table : page.getData()) { System.out.println(table.getFullyQualifiedName()); // Process each table... } diff --git a/v2.0.x/api-reference/sdk/ai-sdk.mdx b/v2.0.x/api-reference/sdk/ai-sdk.mdx index 1264c65b6..29274c369 100644 --- a/v2.0.x/api-reference/sdk/ai-sdk.mdx +++ b/v2.0.x/api-reference/sdk/ai-sdk.mdx @@ -95,7 +95,7 @@ const client = new AISdk({ ```java Java import io.openmetadata.ai.AISdk; -AISdk client = new AISdk.Builder() +AISdk client = AISdk.builder() .host("https://your-openmetadata-instance.com") .token("your-bot-jwt-token") .build(); diff --git a/v2.0.x/api-reference/sdk/go-api-methods.mdx b/v2.0.x/api-reference/sdk/go-api-methods.mdx index 44a19ed8f..c3c4eddbe 100644 --- a/v2.0.x/api-reference/sdk/go-api-methods.mdx +++ b/v2.0.x/api-reference/sdk/go-api-methods.mdx @@ -5,16 +5,15 @@ sidebarTitle: API Methods # Go SDK - API Methods -Once you have instantiated a `Rest` object you can call any of the following methods to perform operations against the OpenMetadata API. +Once you have created a `Client`, call the following methods on any of its services to perform operations against the OpenMetadata API. Examples of services are `client.Tables`, `client.Databases`, and `client.Users`. The examples below use `client.Tables`. They assume `ctx` is a `context.Background()` and that you created `client` as shown in [Go SDK](/v2.0.x/api-reference/sdk/go). -### `Get` method +### `List` Method **Method signature** ```go -func (rest Rest) Get( - path string, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) List( + ctx context.Context, + params *ListTablesParams, +) iter.Seq2[Table, error] ``` **Example** @@ -23,21 +22,22 @@ func (rest Rest) Get( ... func main() { ... - path := "tables" - body, err := rest.Get(path, nil, nil, nil) + for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Name) + } } ``` +`List` fetches the next page of results for you as you loop, so you don't need to handle paging yourself. -### `Post` method +### `GetByID` and `GetByName` Methods **Method signature** ```go -func (rest Rest) Post( - path string, - data map[string]interface{}, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) GetByID(ctx context.Context, id string, params *GetTableByIDParams) (*Table, error) +func (s *TableService) GetByName(ctx context.Context, fqn string, params *GetTableByFQNParams) (*Table, error) ``` **Example** @@ -46,34 +46,45 @@ func (rest Rest) Post( ... func main() { ... - path := "tables" - data := map[string]interface{}{ - "name": "goClientTestTable", - "databaseSchema": "sample_data.ecommerce_db.shopify", - "columns": []map[string]interface{}{ - { - "name": "columnOne", - "dataType": "NUMBER", - }, - { - "name": "columnTwo", - "dataType": "NUMBER", - }, + table, err := client.Tables.GetByName(ctx, "sample_data.ecommerce_db.shopify.dim_customer", nil) + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Id) +} +``` + +### `Create` Method +**Method signature** +```go +func (s *TableService) Create(ctx context.Context, body *CreateTable) (*Table, error) +``` + +**Example** +```go +// main.go +... +func main() { + ... + table, err := client.Tables.Create(ctx, &ometa.CreateTable{ + Name: "goClientTestTable", + DatabaseSchema: "sample_data.ecommerce_db.shopify", + Columns: []ometa.Column{ + {Name: "columnOne", DataType: ometa.ColumnDataTypeNUMBER}, + {Name: "columnTwo", DataType: ometa.ColumnDataTypeNUMBER}, }, + }) + if err != nil { + log.Fatal(err) } - body, err := rest.Post(path, data, nil, nil, nil) + fmt.Println(table.Id) } ``` -### `Put` method +### `CreateOrUpdate` Method **Method signature** ```go -func (rest Rest) Put( - path string, - data map[string]interface{}, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) CreateOrUpdate(ctx context.Context, body *CreateTable) (*Table, error) ``` **Example** @@ -82,38 +93,26 @@ func (rest Rest) Put( ... func main() { ... - path := "tables" - data := map[string]interface{}{ - "name": "goClientTestTable", - "databaseSchema": "sample_data.ecommerce_db.shopify", - "columns": []map[string]interface{}{ - { - "name": "columnOne", - "dataType": "NUMBER", - }, - { - "name": "columnTwo", - "dataType": "NUMBER", - }, - { - "name": "columnThree", - "dataType": "NUMBER", - }, - }, - } - body, err := rest.Put(path, data, nil, nil, nil) + table, err := client.Tables.CreateOrUpdate(ctx, &ometa.CreateTable{ + Name: "goClientTestTable", + DatabaseSchema: "sample_data.ecommerce_db.shopify", + Columns: []ometa.Column{ + {Name: "columnOne", DataType: ometa.ColumnDataTypeNUMBER}, + {Name: "columnTwo", DataType: ometa.ColumnDataTypeNUMBER}, + {Name: "columnThree", DataType: ometa.ColumnDataTypeNUMBER}, + }, + }) + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Id) } ``` -### `Patch` method +### `Patch` Method **Method signature** ```go -func (rest Rest) Patch( - path string, - data []map[string]interface{}, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) Patch(ctx context.Context, id string, ops []JSONPatchOp) (*Table, error) ``` **Example** @@ -122,27 +121,22 @@ func (rest Rest) Patch( ... func main() { ... - path := "tables" - patchPath := fmt.Sprintf("tables/%s", id) - data := []map[string]interface{}{ - { - "op": "add", - "path": "/description", - "value": "This is a test table", - }, - } - body, err := rest.Patch(patchPath, data, nil, nil, nil) + id := table.Id.String() + updated, err := client.Tables.Patch(ctx, id, []ometa.JSONPatchOp{ + {Op: "add", Path: "/description", Value: "This is a test table"}, + }) + if err != nil { + log.Fatal(err) + } + fmt.Println(*updated.Description) } ``` -### `Delete` method +### `Delete` and `DeleteByName` Methods **Method signature** ```go -func (rest Rest) Delete( - path string, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) Delete(ctx context.Context, id string, params *DeleteTableParams) error +func (s *TableService) DeleteByName(ctx context.Context, fqn string, params *DeleteTable1Params) error ``` **Example** @@ -151,11 +145,12 @@ func (rest Rest) Delete( ... func main() { ... - path := fmt.Sprintf("tables/%s", id) - queryParams := map[string]string{ - "hardDelete": "true", - "recursive": "true", - } - rest.Delete(path, nil, nil, queryParams) + err := client.Tables.Delete(ctx, table.Id.String(), &ometa.DeleteTableParams{ + HardDelete: ometa.Bool(true), + Recursive: ometa.Bool(true), + }) + if err != nil { + log.Fatal(err) + } } ``` diff --git a/v2.0.x/api-reference/sdk/go.mdx b/v2.0.x/api-reference/sdk/go.mdx index 3accc2fc8..385b59ab6 100644 --- a/v2.0.x/api-reference/sdk/go.mdx +++ b/v2.0.x/api-reference/sdk/go.mdx @@ -18,49 +18,41 @@ You can add the module to your application with the below command go get github.com/open-metadata/openmetadata-sdk/openmetadata-go-client ``` -## Establish OpenMetadata Server Connection +## Create a Client -To create OpenMetadata Gateway, you will need to establish a connection with *OpenMetadata Server*. The following inputs will be needed: -* `BaseURL`: The url on which your instance of OpenMetadata is up and running (include the port if you need to e.g. `http://localhost:8585`). -* `APIVersion`: pass an empty string -- this will be `v1` for now. -* `Retry`: number of time the request should retry if the status code returned is in `RetryCodes`. Use `0` to use the default value -* `RetryWait`: number of second to wait betwee retries. Pass 0 to use the default value -* `RetryCodes`: HTTP status that will trigger a retry. Pass `nil` to use the default -* `AuthTokenMode`: defaults to `Bearer` -* `AccessToken`: JWT token use to authenticate the request +To talk to OpenMetadata, create a `Client` with the server address and, optionally, settings passed as options: +* `baseURL` (first argument): the address where your OpenMetadata server is running, without the `/api` suffix (include the port if you need to, for example `http://localhost:8585`). The client adds `/api/v1` itself. +* `WithToken(token)`: the JWT token used to authenticate every request. +* `WithAPIVersion(v)`: the API version to call. Defaults to `v1`, so you normally don't set it. +* `WithRetry(count, wait)`: how many times to retry a request, and how long to wait between retries. Defaults to 3 retries, 30 seconds apart. The client retries a request when the server answers `429` or `504`. +* `WithHTTPClient(c)`: use your own `*http.Client`, for example to set a proxy or custom TLS settings. ```go // main.go package main import ( + "context" + "fmt" + "log" + "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" ) func main() { - restConfig := ometa.NewRestConfig( + ctx := context.Background() + client := ometa.NewClient( "http://localhost:8585", - "", // APIVersion - 0, // Retry -> defaults to 3 - 0, // RetryWait -> defaults to 30 seconds - nil, // RetryCodes -> defaults to [429, 504] - "JWTToken", + ometa.WithToken(""), ) -} -``` - - -## Create OpenMetadata Gateway - -Once the connection details are provided, you can create an OpenMetadata Gateway -using the following piece of code. -```go -// main.go -... - -func main() { - ... - rest := ometa.NewRest(restConfig) + for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Name) + } } ``` + +The client has one service for each entity type, such as `client.Tables`, `client.Databases`, and `client.Users`. For more information about the methods every service provides, see [Go SDK - API Methods](/v2.0.x/api-reference/sdk/go-api-methods). diff --git a/v2.0.x/api-reference/sdk/java.mdx b/v2.0.x/api-reference/sdk/java.mdx index 2e45ee68a..ebbf5d4e6 100644 --- a/v2.0.x/api-reference/sdk/java.mdx +++ b/v2.0.x/api-reference/sdk/java.mdx @@ -24,204 +24,148 @@ You can add the below Maven Dependency for the OpenMetadata Java SDK. ``` -## Establish OpenMetadata Server Connection +## Connect to the OpenMetadata Server -To create OpenMetadata Gateway, you will need to establish a connection with *OpenMetadata Server*. The following -inputs will be needed for the same. -* Host Port: The url on which your instance of OpenMetadata is up and running. -* ApiVersion: The value will be "v1". -* Auth Provider: Provide the auth provider with which you need to configure. -* Security Config: Provide the config for the selected auth provider. +To connect to your OpenMetadata server, you need: -```java -OpenMetadataConnection server = new OpenMetadataConnection(); -server.setHostPort("http://localhost:{port}}/api"); -server.setApiVersion("v1"); -server.setAuthProvider(OpenMetadataConnection.AuthProvider.{auth_provider}); -server.setSecurityConfig({security_client_config}); -``` - -## Create OpenMetadata Gateway - -Once the connection details are provided, you can create an OpenMetadata Gateway -using the following piece of code. +* Server URL: The URL where your OpenMetadata instance is running, ending in `/api`. For example, `http://localhost:8585/api`. +* Access token: A JSON Web Token (JWT) for a user or bot. See [Authentication](/v2.0.x/api-reference/authentication) to learn how to get one. ```java -// OpenMetadata Gateway -OpenMetadata openMetadataGateway = new OpenMetadata(server); -``` +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -## Use Java SDK without Authentication -To use the Java SDK without any authentication, you can use `NoOpAuthenticationProvider.java`. \ +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .build(); -```java -NoOpAuthenticationProvider noOpAuthenticationProvider = new NoOpAuthenticationProvider(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` -Establish the [OpenMetadata Server Connection](#establish-openmetadata-server-connection) and provide `noOpAuthenticationProvider` in the config. +Tune the connection with these options. Timeouts are in milliseconds, and `header` adds a custom header to every request: ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.NO_AUTH); +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .connectTimeout(10000) + .readTimeout(30000) + .header("X-Request-Source", "my-app") + .build(); ``` -## Use Java SDK with Authentication. +## Authenticate with a JWT Token -The OpenMetadata Java SDK supports several auth providers: -* [Google](#google) -* [Okta](#okta) -* [Auth0](#auth0) -* [Azure](#azure) -* [OpenMetadata](#openmetadata) +The Java SDK authenticates with a JWT access token that you pass to `accessToken(...)`. This is the same for every sign-in method on your OpenMetadata server, including Google, Okta, Auth0, Azure, and custom OpenID Connect (OIDC). Generate a bot token or a personal access token in OpenMetadata and use it here. -Apart from the above mentioned auth providers, OpenMetadata Java SDK also supports [Custom OIDC](#custom-oidc). +If your server doesn't require authentication, leave out `accessToken(...)`. -### Google -To set up Google as the auth provider, the following details are required: -* Secret Key: Pass the JSON file generated in [Create Service Account](/v2.0.x/deployment/security/google) as the secretKey. +## Use the Fluent API -```java -GoogleSSOClientConfig googleSSOClientConfig = new GoogleSSOClientConfig(); -ssoConfig.setAudience("https://www.googleapis.com/oauth2/v4/token"); -ssoConfig.setSecretKey("{secret_key.json}"); -``` +The fluent classes, such as `Tables`, `Users`, and `Teams`, work with a default client. Register your client once with `OM.init`, and the fluent classes use it: -Provide the Google config while creating the [server connection](#establish-openmetadata-server-connection). ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.GOOGLE); -server.setSecurityConfig(googleSSOClientConfig); +import org.openmetadata.sdk.OM; +import org.openmetadata.sdk.fluent.Tables; -``` +OM.init(client); -### Okta -To set up Okta as the auth provider, the following details should be provided: -* Client ID: Provide the client ID for the service application -* Org URL: It is the same as the ISSUER_URL with v1/token. It is recommended to use a separate authorization server for different applications, rather than using the default authorization server. -* Private Key: Use the Public/Private Key Pair that was generated while [Creating the Service Application](/v2.0.x/deployment/security/okta#okta-sso). When copy-pasting the keys ensure that there are no additional codes and that it is a JSON compatible string. -* Email: Enter the email address -* Scopes: Add the details of the scope created in the Authorization Server. Enter the name of the default scope created. +// Find a table by its fully qualified name +var table = Tables.findByName("mysql-prod.employees.public.employees") + .includeOwners() + .includeTags() + .fetch() + .get(); -```java -OktaSSOClientConfig oktaSSOClientConfig = new OktaSSOClientConfig(); -oktaSSOClientConfig.setClientId("{client_id}"); -oktaSSOClientConfig.setOrgURL("{org_url}/v1/token"); -oktaSSOClientConfig.setPrivateKey("{public/private keypair}"); -oktaSSOClientConfig.setEmail("{email}"); -oktaSSOClientConfig.setScopes({scope_list}); +// Update its description +Tables.findByName("mysql-prod.employees.public.employees") + .fetch() + .withDescription("Updated description") + .save(); ``` -Provide the Okta config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OKTA); -server.setSecurityConfig(oktaSSOClientConfig); -``` +## Use the Service Clients -### Auth0 -To set up Auth0 as the auth provider, the following details are required: -* Client ID: Provide the client ID for the service application -* Secret Key: Provide the client secret. -* Domain: Provide the Auth0 domain. For example `test.us.auth0.com` +Every entity type has a service on the client, such as `client.tables()`, `client.users()`, and `client.dashboards()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. Below are some examples: ```java -Auth0SSOClientConfig auth0SSOClientConfig = new Auth0SSOClientConfig(); -auth0SSOClientConfig.setClientId("{client_id}"); -auth0SSOClientConfig.setSecretKey("{secret_key}"); -auth0SSOClientConfig.setDomain("{domain}"); -``` -Provide the Auth0 config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AUTH_0); -server.setSecurityConfig(auth0SSOClientConfig); -``` +import org.openmetadata.sdk.models.ListParams; -### Azure -To set up Azure as the auth provider, the following details should be provided: -* Client ID: The Application (Client) ID is displayed in the Overview section of the registered application. -* Client Secret: The clientSecret can be accessed from the Certificates & secret section of the application. -* Authority: Use your Microsoft Entra tenant authority. See [Microsoft's OpenID Connect documentation](https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc) for the endpoint format. -* Scopes: Add the details of the scope created. +// Tables +var tables = client.tables().list(new ListParams().setLimit(10)); +for (var table : tables.getData()) { + System.out.println(table.getFullyQualifiedName()); +} -```java -AzureSSOClientConfig azureSSOClientConfig = new AzureSSOClientConfig(); -azureSSOClientConfig.setClientId("{client_id}"); -azureSSOClientConfig.setClientSecret("{client_secret}"); -azureSSOClientConfig.setAuthority("{authority}"); -azureSSOClientConfig.setScopes({scope_list}); -``` -Provide the Azure config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AZURE); -server.setSecurityConfig(azureSSOClientConfig); +// Users +var users = client.users().list(new ListParams().setLimit(10)); + +// Dashboards +var dashboards = client.dashboards().list(new ListParams().setLimit(10)); ``` -### OpenMetadata -To set up OpenMetadata as the auth provider, the following details should be provided: -* JWT Token: Provide the JWT Token. For example `eyJraWQiOiJHYjM4OWEtOWY3Ni1nZGpzLWE5Mmo....XN0aW9uLWJvdEBvcGVubWV0YWRhdGEub3JnIn0.Ku_FHGIS3Id3ARusMaXZDYKcq...Ztap9KDU7nZilNT2Bq-o75aIsgKKmtSuVdBTzpFK8aLGLmRp_8J007t-kpcjIW7Qf0l4...dGb0QqhoZin0JA` +The following examples show how to call an API: + +* Create a table ```java -OpenMetadataJWTClientConfig openMetadataJWTClientConfig = new OpenMetadataJWTClientConfig(); -openMetadataJWTClientConfig.setJwtToken("{jwt_token}"); -``` -Provide the OpenMetadata config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OPENMETADATA); -server.setSecurityConfig(openMetadataJWTClientConfig); -``` +import java.util.List; +import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; -### Custom OIDC -To set up Custom auth provider. The following details are required: -* Client ID: Provide the client ID of the preferred auth provider -* Client Secret: Provide the client secret of your preferred auth provider -* Token Endpoint: Provide the token endpoint of your preferred auth provider +CreateTable request = new CreateTable() + .withName("orders") + .withDatabaseSchema("mysql-prod.employees.public") + .withDescription("Orders placed by customers") + .withColumns(List.of( + new Column() + .withName("order_id") + .withDataType(ColumnDataType.BIGINT) + .withDescription("Primary key"), + new Column() + .withName("status") + .withDataType(ColumnDataType.VARCHAR) + .withDataLength(50))); -```java -CustomOIDCSSOClientConfig customOIDCSSOClientConfig = new CustomOIDCSSOClientConfig(); -config.setClientId("{client_id}"); -config.setSecretKey("{client_secret}"); -config.setTokenEndpoint("{token_endpoint}"); +var table = client.tables().create(request); ``` -Provide the custom auth provider config while creating the [server connection](#establish-openmetadata-server-connection). +* Get a table by fully qualified name + ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.CUSTOM_OIDC); -server.setSecurityConfig(customOIDCSSOClientConfig); +var table = client.tables().getByName("mysql-prod.employees.public.employees", "columns,owners"); ``` -## How to Use APIs Using the Java SDK -You can use an API from the [OpenMetadata Gateway](#create-openmetadata-gateway). -Using OpenMetadata Gateway, you will need to build the client by providing the `class` of the respected API. -Below are some examples: +* Search + ```java -// Dashboards API -DashboardsApi dashboardApi = openMetadataGateway.buildClient(DashboardsApi.class); +String response = client.search() + .query("customer") + .index("table_search_index") + .size(10) + .execute(); +``` -// Tables API -TablesApi tablesApiClient = openMetadataGateway.buildClient(TablesApi.class); +The search call returns the raw JSON response from the server as a string. -// Users API -UsersApi usersApi = openMetadataGateway.buildClient(UsersApi.class); +## Handle Errors -// Locations API -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -``` +When the server returns an error, the SDK throws an `OpenMetadataException`. Use `getStatusCode()` to see which error it was: -Please refer to the examples to access an API: -* Tables API ```java -TablesApi tablesApi = openMetadataGateway.buildClient(TablesApi.class); -tablesApi.addLocationToTable("{table_id}", "{location_id}"); -``` -* Location API -```java -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -CreateLocation createLocation = new CreateLocation(); -Location location = locationsApi.createLocation(createLocation); -``` +import org.openmetadata.sdk.exceptions.OpenMetadataException; -* Elastic Search API -```java -ElasticSearchApi esApi = openMetadataGateway.buildClient(ElasticSearchApi.class); -Response response = esApi.searchEntitiesWithQuery("", "pipeline_search_index", false, 0, 0, null, null, true, "{\"query\":{\"bool\":{}}}", null, false, null ); -String data = IOUtils.toString(response.body().asInputStream(), Charsets.UTF_8); +try { + var table = client.tables().getByName("mysql-prod.employees.public.missing"); +} catch (OpenMetadataException e) { + if (e.getStatusCode() == 404) { + System.out.println("Table not found"); + } else { + System.out.println("Request failed: " + e.getMessage()); + } +} ``` ## More examples diff --git a/v2.0.x/api-reference/sdk/java/info.mdx b/v2.0.x/api-reference/sdk/java/info.mdx index b81f01cc0..30ed55c66 100644 --- a/v2.0.x/api-reference/sdk/java/info.mdx +++ b/v2.0.x/api-reference/sdk/java/info.mdx @@ -6,7 +6,7 @@ sidebarTitle: Java SDK Info # Java SDK -The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers comprehensive support for entity management, authentication, and integration with enterprise Java applications. +The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers support for entity management, search, lineage, and authentication with a JWT token. ## Installation @@ -35,85 +35,87 @@ implementation 'org.open-metadata:openmetadata-sdk:2.0.5' ### Basic Connection ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; -import org.openmetadata.client.auth.BasicAuthProvider; - -// Create client with basic authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new BasicAuthProvider("admin", "admin")) +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.network.HttpMethod; + +// Create a client with a JWT token +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") .build(); -// Health check -if (client.healthCheck()) { - System.out.println("Successfully connected to OpenMetadata!"); -} -``` - -### JWT Authentication - -```java -import org.openmetadata.client.auth.JWTAuthProvider; +OpenMetadataClient client = new OpenMetadataClient(config); -// Create client with JWT authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new JWTAuthProvider("your-jwt-token")) - .build(); +// Check the connection by reading the server version +String version = client.getHttpClient() + .executeForString(HttpMethod.GET, "/v1/system/version", null); +System.out.println("Connected to OpenMetadata: " + version); ``` +For more information about getting a token, see [Authentication](/v2.0.x/api-reference/authentication). + ## Core Functionality ### Working with Entities +Every entity type has a service on the client, such as `client.databaseServices()`, `client.tables()`, and `client.users()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. + #### Database Services ```java -import org.openmetadata.schema.entity.services.DatabaseService; import org.openmetadata.schema.api.services.CreateDatabaseService; +import org.openmetadata.schema.api.services.DatabaseConnection; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.services.connections.database.MysqlConnection; +import org.openmetadata.sdk.models.ListParams; -// List all database services -List services = client.listDatabaseServices(); -System.out.println("Found " + services.size() + " database services"); +// List database services +var services = client.databaseServices().list(new ListParams().setLimit(50)); +System.out.println("Found " + services.getData().size() + " database services"); // Get specific service by name -DatabaseService service = client.getDatabaseServiceByName("mysql-prod"); +DatabaseService service = client.databaseServices().getByName("mysql-prod"); // Create new database service CreateDatabaseService createRequest = new CreateDatabaseService() .withName("new-mysql-service") - .withServiceType(DatabaseServiceType.MYSQL) - .withDescription("Production MySQL database"); - -DatabaseService newService = client.createDatabaseService(createRequest); + .withServiceType(CreateDatabaseService.DatabaseServiceType.Mysql) + .withDescription("Production MySQL database") + .withConnection(new DatabaseConnection().withConfig( + new MysqlConnection() + .withHostPort("localhost:3306") + .withUsername("openmetadata_user"))); + +DatabaseService newService = client.databaseServices().create(createRequest); ``` #### Tables ```java -import org.openmetadata.schema.entity.data.Table; +import java.util.List; import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; +import org.openmetadata.sdk.models.ListParams; // Get table by fully qualified name -Table table = client.getTableByName("mysql-prod.employees.employees"); -if (table != null) { - System.out.println("Table: " + table.getName()); - System.out.println("Columns: " + table.getColumns().size()); -} +Table table = client.tables().getByName("mysql-prod.employees.public.employees", "columns"); +System.out.println("Table: " + table.getName()); +System.out.println("Columns: " + table.getColumns().size()); -// List tables with pagination -EntityList
tables = client.listTables( - 10, // limit - null, // after cursor - "mysql-prod" // service filter -); +// List tables in a schema with pagination +var tables = client.tables().list( + new ListParams() + .setLimit(10) + .addFilter("databaseSchema", "mysql-prod.employees.public")); // Create table CreateTable createTable = new CreateTable() .withName("new_table") - .withDatabaseSchema("mysql-prod.employees") - .withColumns(Arrays.asList( + .withDatabaseSchema("mysql-prod.employees.public") + .withColumns(List.of( new Column() .withName("id") .withDataType(ColumnDataType.BIGINT) @@ -125,7 +127,7 @@ CreateTable createTable = new CreateTable() .withDescription("Employee name") )); -Table newTable = client.createTable(createTable); +Table newTable = client.tables().create(createTable); ``` ### Entity Operations @@ -133,111 +135,83 @@ Table newTable = client.createTable(createTable); #### CRUD Operations ```java -// Create or Update -DatabaseService service = client.createOrUpdateDatabaseService(createRequest); +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.network.HttpMethod; + +// Create or update a table +Table table = client.tables().createOrUpdate(createTable); + +// Create or update a database service +DatabaseService service = client.getHttpClient().execute( + HttpMethod.PUT, "/v1/services/databaseServices", createRequest, DatabaseService.class); // Get by ID -UUID serviceId = UUID.fromString("service-uuid-here"); -DatabaseService service = client.getDatabaseServiceById(serviceId); +UUID serviceId = service.getId(); +DatabaseService sameService = client.databaseServices().get(serviceId); // Delete -client.deleteDatabaseService(serviceId, false); // soft delete -client.deleteDatabaseService(serviceId, true); // hard delete +client.databaseServices().delete(serviceId.toString()); // soft delete +client.databaseServices().delete(serviceId.toString(), Map.of("hardDelete", "true")); // hard delete ``` #### Search and Filtering ```java -// Search tables -SearchRequest searchRequest = new SearchRequest() - .withQuery("customer") - .withEntityTypes(Arrays.asList("table")) - .withSize(50); - -SearchResponse results = client.search(searchRequest); -for (SearchHit hit : results.getHits()) { - System.out.println("Found: " + hit.getDisplayName()); -} +import org.openmetadata.sdk.models.ListParams; + +// Search tables. The response is the raw JSON from the server. +String results = client.search() + .query("customer") + .index("table_search_index") + .size(50) + .execute(); +System.out.println(results); // Advanced filtering -EntityList
customerTables = client.listTables( - 100, - null, - Map.of( - "service", "mysql-prod", - "database", "ecommerce" - ) -); +var customerTables = client.tables().list( + new ListParams() + .setLimit(100) + .addFilter("database", "mysql-prod.ecommerce")); ``` ## Advanced Features -### Authentication Providers - -#### Custom Authentication - -```java -import org.openmetadata.client.auth.AuthProvider; - -public class CustomAuthProvider implements AuthProvider { - private String customToken; - - public CustomAuthProvider(String token) { - this.customToken = token; - } - - @Override - public String getAuthToken() { - return "Bearer " + customToken; - } - - @Override - public void refresh() { - // Implement token refresh logic - } -} - -// Use custom auth provider -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(new CustomAuthProvider("custom-token")) - .build(); -``` +### Authentication -#### OAuth 2.0 Integration +The Java SDK authenticates with a JWT access token. When your token changes, create a new client with the new token: ```java -import org.openmetadata.client.auth.OAuth2AuthProvider; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -OAuth2AuthProvider authProvider = OAuth2AuthProvider.builder() - .clientId("your-client-id") - .clientSecret("your-client-secret") - .tokenUrl("https://auth.provider.com/oauth/token") - .scopes(Arrays.asList("read", "write")) - .build(); +String newToken = "your-new-jwt-token"; -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(authProvider) - .build(); +OpenMetadataClient client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl("https://your-instance.com/api") + .accessToken(newToken) + .build()); ``` ### Error Handling ```java -import org.openmetadata.client.exception.OpenMetadataException; +import org.openmetadata.sdk.exceptions.OpenMetadataException; try { - Table table = client.getTableByName("non-existent-table"); + var table = client.tables().getByName("non-existent-table"); } catch (OpenMetadataException e) { - switch (e.getErrorCode()) { - case NOT_FOUND: + switch (e.getStatusCode()) { + case 404: System.out.println("Table not found"); break; - case UNAUTHORIZED: + case 401: System.out.println("Authentication failed"); break; - case FORBIDDEN: + case 403: System.out.println("Access denied"); break; default: @@ -248,15 +222,22 @@ try { ### Async Operations +The service methods are blocking. To run them in parallel, wrap them in a `CompletableFuture`: + ```java +import java.util.List; import java.util.concurrent.CompletableFuture; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.models.ListParams; -// Async client operations CompletableFuture> servicesFuture = - client.listDatabaseServicesAsync(); + CompletableFuture.supplyAsync( + () -> client.databaseServices().list(new ListParams().setLimit(50)).getData()); CompletableFuture
tableFuture = - client.getTableByNameAsync("mysql-prod.employees.employees"); + CompletableFuture.supplyAsync( + () -> client.tables().getByName("mysql-prod.employees.public.employees", "columns")); // Combine async operations CompletableFuture combinedFuture = CompletableFuture.allOf( @@ -280,39 +261,19 @@ CompletableFuture combinedFuture = CompletableFuture.allOf( ### Client Configuration ```java -import org.openmetadata.client.config.ClientConfig; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -ClientConfig config = ClientConfig.builder() - .connectionTimeout(30000) // 30 seconds +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .connectTimeout(30000) // 30 seconds .readTimeout(60000) // 60 seconds - .retryCount(3) // Retry failed requests 3 times - .enableLogging(true) // Enable request/response logging - .enableMetrics(true) // Enable client metrics - .userAgent("MyApp/1.0") // Custom user agent + .writeTimeout(60000) // 60 seconds + .header("User-Agent", "MyApp/1.0") // Custom header on every request .build(); -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(authProvider) - .config(config) - .build(); -``` - -### Connection Pooling - -```java -import org.openmetadata.client.config.ConnectionPoolConfig; - -ConnectionPoolConfig poolConfig = ConnectionPoolConfig.builder() - .maxTotal(100) // Maximum total connections - .maxPerRoute(20) // Maximum connections per route - .connectionTTL(300000) // Connection TTL in milliseconds - .validateAfterInactivity(10000) // Validate connections after 10s - .build(); - -ClientConfig config = ClientConfig.builder() - .connectionPoolConfig(poolConfig) - .build(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ## Common Use Cases @@ -320,15 +281,26 @@ ClientConfig config = ClientConfig.builder() ### Metadata Discovery ```java -// Discover all tables in a service -String serviceName = "mysql-prod"; +import java.util.ArrayList; +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + +// Discover all tables in a schema +String schemaName = "mysql-prod.employees.public"; List
allTables = new ArrayList<>(); String after = null; do { - EntityList
batch = client.listTables(100, after, serviceName); + var params = new ListParams() + .setLimit(100) + .addFilter("databaseSchema", schemaName); + if (after != null) { + params.setAfter(after); + } + var batch = client.tables().list(params); allTables.addAll(batch.getData()); - after = batch.getAfter(); + after = batch.getPaging().getAfter(); } while (after != null); System.out.println("Discovered " + allTables.size() + " tables"); @@ -337,17 +309,19 @@ System.out.println("Discovered " + allTables.size() + " tables"); ### Bulk Operations ```java +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + // Bulk update table descriptions -List
tables = client.listAllTablesInService("mysql-prod"); +List
tables = client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", "mysql-prod.employees.public")) + .getData(); for (Table table : tables) { if (table.getDescription() == null || table.getDescription().isEmpty()) { - CreateTable updateRequest = new CreateTable() - .withName(table.getName()) - .withDatabaseSchema(table.getDatabaseSchema().getFullyQualifiedName()) - .withDescription("Auto-generated description for " + table.getName()); - - client.createOrUpdateTable(updateRequest); + table.setDescription("Auto-generated description for " + table.getName()); + client.tables().update(table.getId().toString(), table); } } ``` @@ -355,87 +329,61 @@ for (Table table : tables) { ### Lineage Operations ```java -import org.openmetadata.schema.type.EntityLineage; - -// Get table lineage -EntityLineage lineage = client.getTableLineage( - "mysql-prod.employees.employees", - 1, // upstream depth - 1 // downstream depth +// Get table lineage as JSON (1 hop upstream, 1 hop downstream) +String lineage = client.lineage().getLineageByName( + "table", + "mysql-prod.employees.public.employees", + "1", // upstream depth + "1" // downstream depth ); -System.out.println("Upstream entities: " + lineage.getUpstreamEdges().size()); -System.out.println("Downstream entities: " + lineage.getDownstreamEdges().size()); +System.out.println(lineage); ``` -## Spring Boot Integration +For more information about the fluent API for lineage, see [Java SDK for Lineage](/v2.0.x/api-reference/sdk/java/lineage). -### Configuration Class +## Use the Client in Your Application -```java -@Configuration -@EnableConfigurationProperties(OpenMetadataProperties.class) -public class OpenMetadataConfig { - - @Bean - public OpenMetadataClient openMetadataClient(OpenMetadataProperties properties) { - return OpenMetadataClient.builder() - .baseUrl(properties.getBaseUrl()) - .authProvider(new JWTAuthProvider(properties.getJwtToken())) - .build(); - } -} - -@ConfigurationProperties(prefix = "openmetadata") -@Data -public class OpenMetadataProperties { - private String baseUrl; - private String jwtToken; -} -``` - -### Service Layer +Create one `OpenMetadataClient` and share it across your application. If you use a framework such as Spring Boot, register the client as a singleton bean. ```java -@Service -public class MetadataService { +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.models.ListParams; - private final OpenMetadataClient client; +class MetadataService { - public MetadataService(OpenMetadataClient client) { - this.client = client; - } + private final OpenMetadataClient client; - public List
getTablesForService(String serviceName) { - return client.listAllTablesInService(serviceName); + public MetadataService(String baseUrl, String jwtToken) { + this.client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl(baseUrl) + .accessToken(jwtToken) + .build()); } - public Table createTable(CreateTableRequest request) { - CreateTable createTable = new CreateTable() - .withName(request.getName()) - .withDatabaseSchema(request.getSchemaFqn()) - .withColumns(request.getColumns()); - - return client.createTable(createTable); + public java.util.List getTablesForSchema(String schemaFqn) { + return client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", schemaFqn)) + .getData(); } } ``` ## Best Practices -1. **Resource Management**: Always close clients when done -2. **Connection Pooling**: Use connection pooling for high-throughput applications -3. **Error Handling**: Implement proper retry logic and error handling -4. **Authentication**: Use secure authentication methods in production -5. **Async Operations**: Use async methods for better performance in concurrent scenarios -6. **Pagination**: Always handle pagination for large datasets -7. **Caching**: Implement caching for frequently accessed entities +- **Reuse the client**: Create one client and share it instead of creating a new one per request. +- **Handle errors**: Catch `OpenMetadataException` and check the status code. +- **Protect authentication**: Keep your JWT token in a secret store, not in source code. +- **Use async operations**: Wrap calls in `CompletableFuture` for better performance in concurrent scenarios. +- **Handle pagination**: Always handle pagination for large datasets. +- **Cache entities**: Implement caching for frequently accessed entities. ## Performance Tips -- Use batch operations when possible -- Implement connection pooling for high-concurrency applications -- Cache frequently accessed metadata -- Use async operations for better throughput -- Specify only required fields when fetching entities -- Implement proper retry strategies with exponential backoff \ No newline at end of file +- Create one client and reuse it. +- Cache frequently accessed metadata. +- Run independent calls in parallel with `CompletableFuture`. +- Specify only required fields when fetching entities. +- Use filters to narrow lists before you read them. diff --git a/v2.0.x/api-reference/sdk/java/lineage.mdx b/v2.0.x/api-reference/sdk/java/lineage.mdx index 4ed1ded83..2a547fda2 100644 --- a/v2.0.x/api-reference/sdk/java/lineage.mdx +++ b/v2.0.x/api-reference/sdk/java/lineage.mdx @@ -24,12 +24,15 @@ Before using the fluent API, initialize the client: ```java import org.openmetadata.sdk.api.Lineage; import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .jwtToken("") +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("") .build(); +OpenMetadataClient client = new OpenMetadataClient(config); + Lineage.setDefaultClient(client); ``` @@ -38,6 +41,8 @@ Lineage.setDefaultClient(client); Retrieve the lineage graph for an entity by type and ID: ```java +import org.openmetadata.sdk.api.Lineage; + // Get lineage with default depth (1 upstream, 1 downstream) Lineage.LineageGraph graph = Lineage.of("table", tableId).fetch(); @@ -47,9 +52,11 @@ String raw = graph.getRaw(); ### Custom Depth -Control how many hops upstream and downstream are returned: +Control how many hops upstream and downstream are returned. Use a depth of 3 or less, because the server rejects deeper requests: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageGraph graph = Lineage.of("table", tableId) .upstream(3) .downstream(2) @@ -59,14 +66,18 @@ Lineage.LineageGraph graph = Lineage.of("table", tableId) Or set both directions to the same value: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageGraph graph = Lineage.of("table", tableId) - .depth(5) + .depth(3) .fetch(); ``` ### Include Deleted Entities ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageGraph graph = Lineage.of("table", tableId) .includeDeleted(true) .fetch(); @@ -77,6 +88,8 @@ Lineage.LineageGraph graph = Lineage.of("table", tableId) Use `Lineage.connect()` to create an edge between two entities: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("dashboard", dashboardId) @@ -89,6 +102,8 @@ Lineage.LineageEdge edge = Lineage.connect() Map specific columns from the source entity to columns in the target entity: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .fromColumns("customer_id", "order_date") @@ -106,6 +121,8 @@ a `columnsLineage` array inside `lineageDetails`. Associate a pipeline entity that powers the transformation: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("table", targetTableId) @@ -119,6 +136,8 @@ Lineage.LineageEdge edge = Lineage.connect() Attach the SQL query driving the lineage: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("table", targetTableId) @@ -131,6 +150,8 @@ Lineage.LineageEdge edge = Lineage.connect() Combine all options: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .fromColumns("customer_id", "order_date") @@ -147,6 +168,8 @@ Lineage.LineageEdge edge = Lineage.connect() Remove a lineage edge between two entities: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.disconnect() .from("table", sourceTableId) .to("dashboard", dashboardId) @@ -158,6 +181,8 @@ Lineage.disconnect() Export the lineage graph for a given entity by its fully qualified name: ```java +import org.openmetadata.sdk.api.Lineage; + String csv = Lineage.export() .entity("table", "service.database.schema.my_table") .upstream(3) @@ -167,28 +192,37 @@ String csv = Lineage.export() ## Impact Analysis -Analyze which downstream (or upstream) entities are affected by changes to a given entity: +To find the entities affected by a change, fetch the lineage graph in one direction and read the entities from the raw JSON. The `nodes` array lists every entity in the graph. ### Downstream Impact ```java -Lineage.ImpactAnalysis impact = Lineage.impact() - .of("table", tableId) - .downstream() - .depth(3) - .analyze(); +import org.openmetadata.sdk.api.Lineage; -int totalImpacted = impact.getTotalImpactCount(); +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +Lineage.LineageGraph graph = Lineage.of("table", tableId) + .upstream(0) + .downstream(3) + .fetch(); + +JsonNode lineage = new ObjectMapper().readTree(graph.getRaw()); +for (JsonNode node : lineage.path("nodes")) { + System.out.println(node.path("type").asText() + ": " + node.path("fullyQualifiedName").asText()); +} +System.out.println("Impacted entities: " + lineage.path("nodes").size()); ``` ### Upstream Impact ```java -Lineage.ImpactAnalysis impact = Lineage.impact() - .of("dashboard", dashboardId) - .upstream() - .depth(5) - .analyze(); +import org.openmetadata.sdk.api.Lineage; + +Lineage.LineageGraph graph = Lineage.of("dashboard", dashboardId) + .upstream(3) + .downstream(0) + .fetch(); ``` ## OpenLineage Events @@ -197,6 +231,8 @@ The SDK also supports posting [OpenLineage](https://openlineage.io/) standard ev via the `OpenLineage` fluent API: ```java +import org.openmetadata.sdk.api.Lineage; + import org.openmetadata.sdk.fluent.OpenLineage; OpenLineage.setDefaultClient(client); @@ -206,7 +242,7 @@ String response = OpenLineage.event() .withEventType("COMPLETE") .withEventTime("2024-01-15T12:00:00Z") .withJob("my-etl-job", "my-namespace") - .withRun("run-id-123") + .withRun("3f2b9c1e-5d4a-4e7b-8a6c-1d2e3f4a5b6c") .addInput("source_table", "my-namespace") .addOutput("target_table", "my-namespace") .send(); @@ -215,18 +251,20 @@ String response = OpenLineage.event() ### Batch Events ```java +import org.openmetadata.sdk.fluent.OpenLineage; + // Build individual events OpenLineage.RunEventBuilder event1 = OpenLineage.event() .withEventType("START") .withEventTime("2024-01-15T12:00:00Z") .withJob("job-1", "ns") - .withRun("run-1"); + .withRun("7a1c2d3e-4b5f-4a6b-9c8d-0e1f2a3b4c5d"); OpenLineage.RunEventBuilder event2 = OpenLineage.event() .withEventType("COMPLETE") .withEventTime("2024-01-15T12:05:00Z") .withJob("job-1", "ns") - .withRun("run-1"); + .withRun("7a1c2d3e-4b5f-4a6b-9c8d-0e1f2a3b4c5d"); // Send as a batch String response = OpenLineage.batch() @@ -238,25 +276,32 @@ String response = OpenLineage.batch() ## Static API For simpler use cases, the `LineageAPI` class in `org.openmetadata.sdk.api` provides static methods -that wrap the underlying HTTP calls: +that wrap the underlying HTTP calls. They use a shared client, which you set up once with `OpenMetadata.initialize`: ```java +import java.util.Map; import org.openmetadata.sdk.api.LineageAPI; +import org.openmetadata.sdk.client.OpenMetadata; + +OpenMetadata.initialize("http://localhost:8585/api", ""); // Get lineage by entity FQN -String lineage = LineageAPI.getLineage("service.db.schema.table"); +String lineage = LineageAPI.getLineage("table/name/service.db.schema.table"); // Get lineage with depth -String lineage = LineageAPI.getLineage("service.db.schema.table", "3", "2"); +String lineageWithDepth = LineageAPI.getLineage("table/name/service.db.schema.table", "3", "2"); // Get lineage by entity type and ID -String lineage = LineageAPI.getEntityLineage("table", tableId); +String lineageById = LineageAPI.getEntityLineage("table", tableId); // Add lineage (pass a Map matching the AddLineage JSON schema) +Map lineageRequestMap = Map.of("edge", Map.of( + "fromEntity", Map.of("id", sourceTableId, "type", "table"), + "toEntity", Map.of("id", targetTableId, "type", "table"))); String result = LineageAPI.addLineage(lineageRequestMap); // Delete lineage -String result = LineageAPI.deleteLineage("table:fromId", "dashboard:toId"); +String deleted = LineageAPI.deleteLineage("table:" + sourceTableId, "dashboard:" + dashboardId); // Export lineage String csv = LineageAPI.exportLineage("service.db.schema.table", "table", "3", "2"); @@ -267,9 +312,13 @@ String csv = LineageAPI.exportLineage("service.db.schema.table", "table", "3", " All static methods have `CompletableFuture`-based async variants: ```java -CompletableFuture future = LineageAPI.getLineageAsync("service.db.schema.table"); +import java.util.concurrent.CompletableFuture; +import org.openmetadata.sdk.api.LineageAPI; + +CompletableFuture future = LineageAPI.getLineageAsync("table/name/service.db.schema.table"); future.thenAccept(lineage -> System.out.println("Lineage: " + lineage)); -CompletableFuture addFuture = LineageAPI.addLineageAsync(request); -CompletableFuture deleteFuture = LineageAPI.deleteLineageAsync("table:id1", "dashboard:id2"); +CompletableFuture addFuture = LineageAPI.addLineageAsync(lineageRequestMap); +CompletableFuture deleteFuture = LineageAPI.deleteLineageAsync( + "table:" + sourceTableId, "dashboard:" + dashboardId); ``` diff --git a/v2.0.x/api-reference/sdk/overview.mdx b/v2.0.x/api-reference/sdk/overview.mdx index d7c498c9b..786cf8d03 100644 --- a/v2.0.x/api-reference/sdk/overview.mdx +++ b/v2.0.x/api-reference/sdk/overview.mdx @@ -2,6 +2,8 @@ title: OpenMetadata SDKs description: 'Official client libraries for Python, Java, and Go to integrate with OpenMetadata APIs. Type-safe, full-featured SDKs for metadata management and automation.' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # OpenMetadata SDKs @@ -25,7 +27,7 @@ Official client libraries provide type-safe, full-featured access to OpenMetadat - Full-featured Python client + Original Client and SDK 2.0 (`metadata.sdk`) Enterprise Java integration @@ -44,15 +46,24 @@ Perfect for: - ML pipeline automation - Data quality automation +SDK 2.0 (`metadata.sdk`, OpenMetadata 1.10.0 and later): + + + +Original client: + ```python from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( OpenMetadataConnection, ) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) from metadata.ingestion.ometa.ometa_api import OpenMetadata server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -69,13 +80,15 @@ Perfect for: - Legacy system integration ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; + +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .build(); -OpenMetadataClient client = new OpenMetadataClient( - "http://localhost:8585/api", - "your-jwt-token" -); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ### Go SDK @@ -86,11 +99,11 @@ Perfect for: - High-performance services ```go -import "github.com/open-metadata/openmetadata-go-client" +import "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" -client := openmetadata.NewClient( - "http://localhost:8585/api", - "your-jwt-token", +client := ometa.NewClient( + "http://localhost:8585", + ometa.WithToken("your-jwt-token"), ) ``` diff --git a/v2.0.x/api-reference/sdk/python.mdx b/v2.0.x/api-reference/sdk/python.mdx index 024fc6394..ec48d9bbc 100644 --- a/v2.0.x/api-reference/sdk/python.mdx +++ b/v2.0.x/api-reference/sdk/python.mdx @@ -3,6 +3,8 @@ title: Python SDK | OpenMetadata Python SDK Documentation description: Master OpenMetadata'sPython SDK with comprehensive documentation, code examples, and API guides. Build powerful data discovery and governance solutions. sidebarTitle: Overview --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -17,7 +19,7 @@ We are now going to present a high-level Python API as a type-safe and gentle wr - Make sure to use the same `openmetadata-ingestion` version as your server version. For example, if you have the OpenMetadata server at version 2.0.5, you need to install: -```python +```bash pip install "openmetadata-ingestion~=2.0.5.0" ``` @@ -30,7 +32,15 @@ In the [OpenMetadata Design](/v2.0.x/developers/architecture), we have been diss This means that whenever we need to interact with the metadata system or develop a new connector or logic, we have to make sure that we pass the proper inputs and handle the types of outputs. -## Introducing the Python API + + +## SDK 2.0 Quick Start + +Connect with `configure()`, then create, update, and delete a table: + + + +## Introducing the Python API (Original Client) Let's suppose that we have our local OpenMetadata server running at `http:localhost:8585`. We can play with it with simple `cURL` or `httpie` commands, and if we just want to take a look at the Entity instances we have lying around, that might probably be enough. However, let's imagine that we want to create or update an ML Model Entity with a `PUT`. To do so, we need to make sure that we are providing a proper JSON, covering all the attributes and types required by the Entity definition. @@ -320,8 +330,8 @@ class CreateDatabaseRequest(BaseModel): None, description='Description of the database instance. What it has and how to use it.', ) - owner: Optional[entityReference.EntityReference] = Field( - None, description='Owner of this database' + owners: Optional[entityReferenceList.EntityReferenceList] = Field( + None, description='Owners of this database' ) service: basic.FullyQualifiedEntityName = Field( ..., @@ -335,7 +345,7 @@ class CreateDatabaseRequest(BaseModel): Note how the only non-optional fields are `name` and `service`. The type of `service`, however, is `FullyQualifiedEntityName`. This is expected, as there we need to pass the information of an existing Entity. In our case, the `fullyQualifiedName` of the `DatabaseService` we just created. -In the case of the `owner` field, repeating the exercise and reviewing the required fields to instantiate an `EntityReference` we notice how we need to pass an `id: uuid.UUID` and `type: str`. There we need to specify the `id` and `type` of an `User`. +The `owners` field takes a list of `EntityReference`. To instantiate an `EntityReference`, pass an `id: uuid.UUID` and `type: str`. Specify the `id` and `type` of a `User`. **Querying by name** @@ -404,8 +414,8 @@ Let's now update the `Table` by adding an owner. This will require us to create First, make sure that no owner has been set during the creation: ```python -print(table_entity.owner) -# None +print(table_entity.owners) +# root=[] ``` Now, create a `User`: @@ -418,19 +428,19 @@ user = metadata.create_or_update( ) ``` -Update our instance of `create_table` to add the `owner` field (we need to use the `Create` class as we'll run a `PUT`), and update the Entity: +Update your `create_table` instance to add the `owners` field. Use the `Create` class, because this runs a `PUT`. Then update the Entity: ```python from metadata.generated.schema.type.entityReference import EntityReference -create_table.owner = EntityReference(id=user.id, type="user") +create_table.owners = [EntityReference(id=user.id, type="user")] updated_table_entity = metadata.create_or_update(create_table) -print(updated_table_entity.owner) -# EntityReference(id=Uuid(__root__=UUID('48793f0c-5308-45c1-9bf4-06a82c8d7bf9')), type='user', name='random-user', description=None, displayName=None, href=Href(__root__=AnyUrl('http://localhost:8585/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9', scheme='http', host='localhost', host_type='int_domain', port='8585', path='/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9'))) +print(updated_table_entity.owners.root[0].name) +# random-user ``` -If we did not save the `updated_table_entity` variable, we should need to query it to review the `owner` field. We can run the `get_by_name` using the proper FQN definition for `Table`s: +If you didn't save the `updated_table_entity` variable, query it to review the `owners` field. Run `get_by_name` with the FQN of the table: ```python my_table = metadata.get_by_name(entity=Table, fqn="test-service-table.test-db.test-schema.test") diff --git a/v2.0.x/api-reference/sdk/python/entities/ml-model.mdx b/v2.0.x/api-reference/sdk/python/entities/ml-model.mdx index 97e568473..604c97238 100644 --- a/v2.0.x/api-reference/sdk/python/entities/ml-model.mdx +++ b/v2.0.x/api-reference/sdk/python/entities/ml-model.mdx @@ -35,7 +35,7 @@ There are some common questions with lifecycle tools, such as _Where (URL) is th This information, together with the rest of the features brought by OpenMetadata, lets us also manage topics such as schema changes in the sources or feature drifts, with the corresponding alerting systems. -While we can already extract certain pieces of information automatically via our Connectors (e.g., [Mlflow](/v2.0.x/connectors/ml-model/mlflow)), there are attributes that we'll need to fill in by ourselves. Thanks to the [Solution Design](/v2.0.x/main-concepts/high-level-design) of OpenMetadata and the [Python SDK](/v2.0.x/api-reference/sdk/python), this is going to be a rather easy task that will unlock the full power of your **organization's metadata**. +While we can already extract certain pieces of information automatically via our Connectors, for example [Mlflow](/v2.0.x/connectors/ml-model/mlflow), there are attributes that we'll need to fill in by ourselves. Thanks to the [Solution Design](/v2.0.x/main-concepts/high-level-design) of OpenMetadata and the [Python SDK](/v2.0.x/api-reference/sdk/python), this is going to be a rather easy task that will unlock the full power of your **organization's metadata**. ## Properties Now that we have a clearer view of what we are trying to achieve, let's jump into a deeper view on the `MlModel` Entity [definition](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/entity/data/mlmodel.json): @@ -43,7 +43,7 @@ Now that we have a clearer view of what we are trying to achieve, let's jump int - The `name` and `algorithm` are the only required properties when [creating](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/api/data/createMlModel.json) an `MlModel`. We can just bring the top shell to the catalogue automatically and then choose which models we want to enrich. - The `dashboard` is a reference to a Dashboard Entity present in OpenMetadata (what we call an `EntityReference`). This should be a dashboard we have built that shows the evolution of our performance metrics. The **transparency** on ML services is integral, and that is why we have added it to the `MlModel` properties. - A server with the URL on where to reach the model **endpoint**, to `POST` input data or retrieve a prediction. -- The mlStore specifies the **location** containing the model. Here we support both passing a URI with the object (e.g. `pkl`) location and/or a Docker image in its repository. +- The mlStore specifies the **location** containing the model. Here we support both passing a URI with the object, for example `pkl` location and/or a Docker image in its repository. - With `mlHyperParameters` we can add the `name`, `value` and `description` of the used hyperparameters. On top of this information, we can also have common metadata attributes, such as the Owner, tags, followers or **versioning**. @@ -80,7 +80,7 @@ MlFeature( Some properties that we can define when instantiating an `MlFeature` are the name, the `dataType` and the `featureAlgorithm`. Now, the question is: Are we being thorough in describing what is really going on? Are we going to be able to detect at any point in the future if this model is based on biased predictors (such as gender)? -Here we want to give more **depth**. In order to do so, we can inform another property of the `MlFeature`, which are the `MlFeatureSource`s. The idea is that any feature can be based on an arbitrary number of real/physical sources (e.g., the columns of a Table), and informing this field will allow us to obtain this **relationship**. +Here we want to give more **depth**. In order to do so, we can inform another property of the `MlFeature`, which are the `MlFeatureSource`s. The idea is that any feature can be based on an arbitrary number of real/physical sources, for example the columns of a Table, and informing this field will allow us to obtain this **relationship**. If we add this extra information, our feature will look like this: @@ -117,9 +117,18 @@ Thanks to this extra piece of information, we now can run the following method o ```python from metadata.ingestion.ometa.ometa_api import OpenMetadata -from metadata.ingestion.ometa.openmetadata_rest import MetadataServerConfig +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) -server_config = MetadataServerConfig(api_endpoint="http://localhost:8585/api") +server_config = OpenMetadataConnection( + hostPort="http://localhost:8585/api", + authProvider="openmetadata", + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), +) metadata = OpenMetadata(server_config) metadata.add_mlmodel_lineage(model=my_mlmodel_entity) diff --git a/v2.0.x/api-reference/sdk/python/overview.mdx b/v2.0.x/api-reference/sdk/python/overview.mdx index c193ace70..828043502 100644 --- a/v2.0.x/api-reference/sdk/python/overview.mdx +++ b/v2.0.x/api-reference/sdk/python/overview.mdx @@ -1,7 +1,10 @@ --- title: Python SDK Overview +sidebarTitle: Original Client and SDK 2.0 description: 'Full-featured Python client library for OpenMetadata integration' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -15,7 +18,17 @@ Install the OpenMetadata Python SDK using pip: pip install openmetadata-ingestion ``` -## Quick Start + + +## Quick Start: SDK 2.0 + +Connect with `configure()`, then create, update, and delete a table: + + + +## Quick Start: Original Client + +Connect with `OpenMetadataConnection`, then read and update entities: ### Basic Connection @@ -31,7 +44,7 @@ from metadata.generated.schema.security.client.openMetadataJWTClientConfig impor # Configure connection server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -62,7 +75,7 @@ table = metadata.get_by_name( ) if table: - print(f"Table: {table.name}") + print(f"Table: {table.name.root}") print(f"Columns: {len(table.columns) if table.columns else 0}") ``` @@ -106,7 +119,7 @@ table = metadata.get_by_name( # List entities with pagination tables = metadata.list_entities( entity=Table, - fields=["owner", "tags"], + fields=["owners", "tags"], limit=50 ) ``` @@ -117,12 +130,12 @@ tables = metadata.list_entities( # Generator for large datasets all_tables = metadata.list_all_entities( entity=Table, - fields=["owner", "columns"], - params={"service": "your-service-name"} + fields=["owners", "columns"], + params={"databaseSchema": "your-service.your-database.your-schema"} ) for table in all_tables: - print(f"Processing table: {table.name}") + print(f"Processing table: {table.name.root}") ``` ### Entity References @@ -136,26 +149,26 @@ table_ref = metadata.get_entity_reference( # Use in other entity creation if table_ref: - print(f"Table reference: {table_ref.id}") + print(f"Table reference: {table_ref.id.root}") ``` ## Advanced Features -### Custom Configuration +### Validating a Custom Certificate Authority (CA) Certificate + +To trust a private CA, pass the path to its certificate in `sslConfig`: ```python -# Using custom authentication -from metadata.generated.schema.security.client.basicAuthenticationProvider import ( - BasicAuthenticationProvider, -) +from metadata.generated.schema.security.ssl.validateSSLClientConfig import ValidateSslClientConfig server_config = OpenMetadataConnection( hostPort="https://your-openmetadata-instance.com/api", - authProvider="basic", - securityConfig=BasicAuthenticationProvider( - username="your-username", - password="your-password" + authProvider="openmetadata", + securityConfig=OpenMetadataJWTClientConfig( + jwtToken="your-jwt-token" ), + verifySSL="validate", + sslConfig=ValidateSslClientConfig(caCertificate="/path/to/rootCert"), ) metadata = OpenMetadata(server_config) @@ -164,18 +177,10 @@ metadata = OpenMetadata(server_config) ### Error Handling ```python -from metadata.ingestion.ometa.ometa_api import ( - OpenMetadata, - InvalidEntityException, - EmptyPayloadException -) - -try: - table = metadata.get_by_name(entity=Table, fqn="non-existent-table") -except InvalidEntityException as e: - print(f"Invalid entity: {e}") -except EmptyPayloadException as e: - print(f"No data received: {e}") +# get_by_name returns None when the entity does not exist +table = metadata.get_by_name(entity=Table, fqn="non-existent-table") +if table is None: + print("Table not found") ``` ### Working with Versions @@ -200,11 +205,11 @@ all_tables = metadata.list_all_entities(entity=Table) matching_tables = [ table for table in all_tables - if "customer" in table.name.lower() + if "customer" in table.name.root.lower() ] for table in matching_tables: - print(f"Found customer table: {table.fullyQualifiedName}") + print(f"Found customer table: {table.fullyQualifiedName.root}") ``` ### Metadata Automation @@ -213,30 +218,28 @@ for table in matching_tables: # Bulk update table descriptions tables_to_update = metadata.list_all_entities( entity=Table, - params={"service": "production-db"} + params={"databaseSchema": "production-service.production-db.public"} ) for table in tables_to_update: if not table.description: # Update with a default description - table.description = f"Production table: {table.name}" + table.description = f"Production table: {table.name.root}" metadata.create_or_update(data=table) ``` ### Lineage Management ```python -from metadata.generated.schema.type.entityLineage import EntityLineage - -# Get table lineage +# Get table lineage (returns a dict) lineage = metadata.get_lineage_by_name( entity=Table, fqn="service.database.schema.table" ) if lineage: - print(f"Upstream entities: {len(lineage.upstreamEdges)}") - print(f"Downstream entities: {len(lineage.downstreamEdges)}") + print(f"Upstream edges: {len(lineage['upstreamEdges'])}") + print(f"Downstream edges: {len(lineage['downstreamEdges'])}") ``` ## API Reference diff --git a/v2.0.x/api-reference/teams-and-users/teams/create.mdx b/v2.0.x/api-reference/teams-and-users/teams/create.mdx index 28f495da5..70ba29f4a 100644 --- a/v2.0.x/api-reference/teams-and-users/teams/create.mdx +++ b/v2.0.x/api-reference/teams-and-users/teams/create.mdx @@ -58,7 +58,7 @@ Create a new team for organizing users and controlling access to data assets. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -81,8 +81,8 @@ Create a new team for organizing users and controlling access to data assets. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -105,20 +105,23 @@ request = CreateTeamRequest( ) team = Teams.create(request) -print(f"Created: {team.fullyQualifiedName}") +print(f"Created: {team.fullyQualifiedName.root}") ``` ```java POST /v1/teams -import static org.openmetadata.sdk.fluent.Teams.*; - -// Create using builder pattern -var team = Teams.builder() - .name("Accounting") - .teamType("Group") - .displayName("Accounting") - .description("Accounting team under Finance") - .parents(List.of("4f87a3ea-d798-4509-8c64-5b11f8a96f89")) - .create(); +import java.util.List; +import java.util.UUID; +import org.openmetadata.schema.api.teams.CreateTeam; + +// client is an initialized OpenMetadataClient. +var request = new CreateTeam() + .withName("Accounting") + .withTeamType(CreateTeam.TeamType.GROUP) + .withDisplayName("Accounting") + .withDescription("Accounting team under Finance") + .withParents(List.of(UUID.fromString("4f87a3ea-d798-4509-8c64-5b11f8a96f89"))); + +var team = client.teams().create(request); ``` ```bash POST /v1/teams diff --git a/v2.0.x/api-reference/teams-and-users/teams/delete.mdx b/v2.0.x/api-reference/teams-and-users/teams/delete.mdx index f3ec3fd9b..d34991d17 100644 --- a/v2.0.x/api-reference/teams-and-users/teams/delete.mdx +++ b/v2.0.x/api-reference/teams-and-users/teams/delete.mdx @@ -51,11 +51,11 @@ Teams.delete( ) # Delete by name -Teams.delete_by_name("Accounting") +Teams.delete(Teams.retrieve_by_name("Accounting").id) # Delete by name with options -Teams.delete_by_name( - "Accounting", +Teams.delete( + Teams.retrieve_by_name("Accounting").id, hard_delete=True ) @@ -64,22 +64,23 @@ Teams.restore("449b5f25-4cbb-42db-8f71-3be2c5cd888a") ``` ```java DELETE /v1/teams/{id} -import static org.openmetadata.sdk.fluent.Teams.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "449b5f25-4cbb-42db-8f71-3be2c5cd888a"; // Soft delete -Teams.delete("449b5f25-4cbb-42db-8f71-3be2c5cd888a").execute(); +client.teams().delete(id); -// Hard delete -Teams.delete("449b5f25-4cbb-42db-8f71-3be2c5cd888a") - .hardDelete() - .execute(); +// Restore +client.teams().restore(id); -// Delete by name -Teams.deleteByName("Accounting") - .execute(); +// Hard delete +client.teams().delete(id, Map.of("hardDelete", "true")); -// Restore -Teams.restore("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); +// Delete by name: look up the ID first +var team = client.teams().getByName("Accounting"); +client.teams().delete(team.getId().toString()); ``` ```bash DELETE /v1/teams/{id} diff --git a/v2.0.x/api-reference/teams-and-users/teams/list.mdx b/v2.0.x/api-reference/teams-and-users/teams/list.mdx index 8839a337a..529d3fee8 100644 --- a/v2.0.x/api-reference/teams-and-users/teams/list.mdx +++ b/v2.0.x/api-reference/teams-and-users/teams/list.mdx @@ -47,49 +47,47 @@ configure( # List first page teams = Teams.list(limit=50) -for team in teams.data: - print(f"{team.fullyQualifiedName} ({team.teamType})") +for team in teams.entities: + print(f"{team.fullyQualifiedName.root} ({team.teamType.value})") # List all with auto-pagination for team in Teams.list_all(): - print(f"{team.fullyQualifiedName}") + print(f"{team.fullyQualifiedName.root}") # Filter by parent team teams = Teams.list( - parentTeam="Finance", + filters={"parentTeam": "Finance"}, fields=["users", "parents", "policies"], limit=50 ) -for team in teams.data: - print(f"{team.fullyQualifiedName}") +for team in teams.entities: + print(f"{team.fullyQualifiedName.root}") if team.users: - print(f" Users: {[u.name for u in team.users]}") + print(f" Users: {[u.name for u in team.users.root]}") if team.parents: - print(f" Parents: {[p.name for p in team.parents]}") + print(f" Parents: {[p.name for p in team.parents.root]}") ``` ```java GET /v1/teams -import static org.openmetadata.sdk.fluent.Teams.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Teams.list() - .limit(50) - .execute(); - -for (var team : result.getData()) { - System.out.println(team.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.teams().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by parent team with fields -var result = Teams.list() - .parentTeam("Finance") - .fields("users", "parents", "policies") - .limit(50) - .execute(); - -for (var team : result.getData()) { - System.out.println(team.getFullyQualifiedName()); +var filtered = new ListParams() + .addFilter("parentTeam", "Finance") + .setFields("users,parents,policies") + .setLimit(50); +var filteredPage = client.teams().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` diff --git a/v2.0.x/api-reference/teams-and-users/teams/retrieve.mdx b/v2.0.x/api-reference/teams-and-users/teams/retrieve.mdx index dcb6c1464..afa2a06c2 100644 --- a/v2.0.x/api-reference/teams-and-users/teams/retrieve.mdx +++ b/v2.0.x/api-reference/teams-and-users/teams/retrieve.mdx @@ -16,7 +16,7 @@ Get a single team by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `users,parents,children,policies,domains,owners`). + Comma-separated list of fields to include, for example `users,parents,children,policies,domains,owners`. @@ -28,7 +28,7 @@ Get a single team by its unique ID or fully qualified name. Use `GET /v1/teams/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the team (e.g., `Accounting`). + Fully qualified name of the team, for example `Accounting`. @@ -51,7 +51,7 @@ configure( # Get by ID team = Teams.retrieve("449b5f25-4cbb-42db-8f71-3be2c5cd888a") -print(f"{team.fullyQualifiedName}: {team.teamType}") +print(f"{team.fullyQualifiedName.root}: {team.teamType.value}") # Get by ID with fields team = Teams.retrieve( @@ -70,25 +70,21 @@ team = Teams.retrieve_by_name( ``` ```java GET /v1/teams/{id} -import static org.openmetadata.sdk.fluent.Teams.*; - -// Get by ID -var team = Teams.retrieve("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); +// client is an initialized OpenMetadataClient. +var team = client.teams().get("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); // Get by ID with fields -var team = Teams.retrieve( +var teamWithFields = client.teams().get( "449b5f25-4cbb-42db-8f71-3be2c5cd888a", - "users,parents,policies" -); + "users,parents,policies"); // Get by fully qualified name -var team = Teams.retrieveByName("Accounting"); +var teamByName = client.teams().getByName("Accounting"); // Get by name with fields -var team = Teams.retrieveByName( +var teamByNameWithFields = client.teams().getByName( "Accounting", - "users,parents,children" -); + "users,parents,children"); ``` ```bash GET /v1/teams/{id} diff --git a/v2.0.x/api-reference/teams-and-users/teams/update.mdx b/v2.0.x/api-reference/teams-and-users/teams/update.mdx index 23bb6b1c3..20b1f332c 100644 --- a/v2.0.x/api-reference/teams-and-users/teams/update.mdx +++ b/v2.0.x/api-reference/teams-and-users/teams/update.mdx @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -63,8 +63,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -83,16 +83,16 @@ team.description = "Updated: Accounting team handling all financial reporting" team.displayName = "Accounting & Reporting" updated = Teams.update(team) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/teams/{id} -import static org.openmetadata.sdk.fluent.Teams.*; - -// Retrieve, modify, and update -var team = Teams.retrieve("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); +// client is an initialized OpenMetadataClient. +var teamId = "449b5f25-4cbb-42db-8f71-3be2c5cd888a"; +var team = client.teams().get(teamId); team.setDescription("Updated: Accounting team handling all financial reporting"); -var updated = Teams.update(team); + +var updated = client.teams().update(teamId, team); ``` ```bash PATCH /v1/teams/{id} diff --git a/v2.0.x/api-reference/teams-and-users/teams/versions.mdx b/v2.0.x/api-reference/teams-and-users/teams/versions.mdx index 311e58057..b82b6a399 100644 --- a/v2.0.x/api-reference/teams-and-users/teams/versions.mdx +++ b/v2.0.x/api-reference/teams-and-users/teams/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/teams/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/teams/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Teams @@ -40,31 +42,29 @@ configure( # List all versions versions = Teams.get_versions("449b5f25-4cbb-42db-8f71-3be2c5cd888a") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version team_v1 = Teams.get_specific_version( "449b5f25-4cbb-42db-8f71-3be2c5cd888a", "0.1" ) -print(f"Original name: {team_v1.name}") +print(f"Original name: {team_v1.name.root}") ``` ```java GET /v1/teams/{id}/versions -import static org.openmetadata.sdk.fluent.Teams.*; +// client is an initialized OpenMetadataClient. +var id = "449b5f25-4cbb-42db-8f71-3be2c5cd888a"; // List all versions -var history = Teams.getVersions("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); - +var history = client.teams().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Teams.getSpecificVersion( - "449b5f25-4cbb-42db-8f71-3be2c5cd888a", - 0.1 -); +var v1 = client.teams().getVersion(id, 0.1); System.out.println("Name: " + v1.getName()); ``` diff --git a/v2.0.x/api-reference/teams-and-users/users/create.mdx b/v2.0.x/api-reference/teams-and-users/users/create.mdx index adcf2f94c..ec4d8adcd 100644 --- a/v2.0.x/api-reference/teams-and-users/users/create.mdx +++ b/v2.0.x/api-reference/teams-and-users/users/create.mdx @@ -51,8 +51,8 @@ Starting in OpenMetadata 2.0.3, assigning a user to a closed team (`isJoinable: Array of persona references to assign to the user. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -64,7 +64,7 @@ Starting in OpenMetadata 2.0.3, assigning a user to a closed team (`isJoinable: - Timezone of the user (e.g., `America/New_York`). + Timezone of the user, for example `America/New_York`. @@ -90,19 +90,20 @@ request = CreateUserRequest( ) user = Users.create(request) -print(f"Created: {user.fullyQualifiedName}") +print(f"Created: {user.fullyQualifiedName.root}") ``` ```java POST /v1/users -import static org.openmetadata.sdk.fluent.Users.*; - -// Create using builder pattern -var user = Users.builder() - .name("aaron_johnson0") - .displayName("Aaron Johnson") - .email("aaron_johnson0@gmail.com") - .description("Data analyst in the Sales team") - .create(); +import org.openmetadata.schema.api.teams.CreateUser; + +// client is an initialized OpenMetadataClient. +var request = new CreateUser() + .withName("aaron_johnson0") + .withDisplayName("Aaron Johnson") + .withEmail("aaron_johnson0@gmail.com") + .withDescription("Data analyst in the Sales team"); + +var user = client.users().create(request); ``` ```bash POST /v1/users diff --git a/v2.0.x/api-reference/teams-and-users/users/delete.mdx b/v2.0.x/api-reference/teams-and-users/users/delete.mdx index f794ffadf..802f00d03 100644 --- a/v2.0.x/api-reference/teams-and-users/users/delete.mdx +++ b/v2.0.x/api-reference/teams-and-users/users/delete.mdx @@ -28,7 +28,7 @@ Delete a user by ID or fully qualified name. Supports soft delete (default), har Use `DELETE /v1/users/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the user (e.g., `aaron_johnson0`). + Fully qualified name of the user, for example `aaron_johnson0`. @@ -67,11 +67,11 @@ Users.delete( ) # Delete by name -Users.delete_by_name("aaron_johnson0") +Users.delete(Users.retrieve_by_name("aaron_johnson0").id) # Delete by name with options -Users.delete_by_name( - "aaron_johnson0", +Users.delete( + Users.retrieve_by_name("aaron_johnson0").id, hard_delete=True ) @@ -80,22 +80,23 @@ Users.restore("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") ``` ```java DELETE /v1/users/{id} -import static org.openmetadata.sdk.fluent.Users.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "77655e6e-ad33-49da-bbca-db4ba4d4e2cd"; // Soft delete -Users.delete("77655e6e-ad33-49da-bbca-db4ba4d4e2cd").execute(); +client.users().delete(id); -// Hard delete -Users.delete("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") - .hardDelete() - .execute(); +// Restore +client.users().restore(id); -// Delete by name -Users.deleteByName("aaron_johnson0") - .execute(); +// Hard delete +client.users().delete(id, Map.of("hardDelete", "true")); -// Restore -Users.restore("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); +// Delete by name: look up the ID first +var user = client.users().getByName("aaron_johnson0"); +client.users().delete(user.getId().toString()); ``` ```bash DELETE /v1/users/{id} diff --git a/v2.0.x/api-reference/teams-and-users/users/list.mdx b/v2.0.x/api-reference/teams-and-users/users/list.mdx index d222cab92..6a8a7d730 100644 --- a/v2.0.x/api-reference/teams-and-users/users/list.mdx +++ b/v2.0.x/api-reference/teams-and-users/users/list.mdx @@ -55,52 +55,50 @@ configure( # List first page users = Users.list(limit=50) -for user in users.data: - print(f"{user.fullyQualifiedName}") +for user in users.entities: + print(f"{user.fullyQualifiedName.root}") # List all with auto-pagination for user in Users.list_all(): - print(f"{user.fullyQualifiedName}") + print(f"{user.fullyQualifiedName.root}") # Filter by team with fields users = Users.list( - team="Sales", + filters={"team": "Sales"}, fields=["teams", "roles", "domains"], limit=50 ) -for user in users.data: - print(f"{user.fullyQualifiedName}") +for user in users.entities: + print(f"{user.fullyQualifiedName.root}") if user.teams: - print(f" Teams: {[t.name for t in user.teams]}") + print(f" Teams: {[t.name for t in user.teams.root]}") if user.roles: - print(f" Roles: {[r.name for r in user.roles]}") + print(f" Roles: {[r.name for r in user.roles.root]}") # Filter bot accounts -bots = Users.list(isBot=True, limit=50) +bots = Users.list(filters={"isBot": "true"}, limit=50) ``` ```java GET /v1/users -import static org.openmetadata.sdk.fluent.Users.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Users.list() - .limit(50) - .execute(); - -for (var user : result.getData()) { - System.out.println(user.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.users().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by team with fields -var result = Users.list() - .team("Sales") - .fields("teams", "roles", "domains") - .limit(50) - .execute(); - -for (var user : result.getData()) { - System.out.println(user.getFullyQualifiedName()); +var filtered = new ListParams() + .addFilter("team", "Sales") + .setFields("teams,roles,domains") + .setLimit(50); +var filteredPage = client.users().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` diff --git a/v2.0.x/api-reference/teams-and-users/users/retrieve.mdx b/v2.0.x/api-reference/teams-and-users/users/retrieve.mdx index 3cac49182..5e8ec215e 100644 --- a/v2.0.x/api-reference/teams-and-users/users/retrieve.mdx +++ b/v2.0.x/api-reference/teams-and-users/users/retrieve.mdx @@ -16,7 +16,7 @@ Get a single user by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `teams,roles,personas,domains,follows,owns`). + Comma-separated list of fields to include, for example `teams,roles,personas,domains,follows,owns`. @@ -28,7 +28,7 @@ Get a single user by its unique ID or fully qualified name. Use `GET /v1/users/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the user (e.g., `aaron_johnson0`). + Fully qualified name of the user, for example `aaron_johnson0`. @@ -51,7 +51,7 @@ configure( # Get by ID user = Users.retrieve("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") -print(f"{user.fullyQualifiedName}: {user.email}") +print(f"{user.fullyQualifiedName.root}: {user.email.root}") # Get by ID with fields user = Users.retrieve( @@ -70,25 +70,21 @@ user = Users.retrieve_by_name( ``` ```java GET /v1/users/{id} -import static org.openmetadata.sdk.fluent.Users.*; - -// Get by ID -var user = Users.retrieve("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); +// client is an initialized OpenMetadataClient. +var user = client.users().get("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); // Get by ID with fields -var user = Users.retrieve( +var userWithFields = client.users().get( "77655e6e-ad33-49da-bbca-db4ba4d4e2cd", - "teams,roles,domains" -); + "teams,roles,domains"); // Get by fully qualified name -var user = Users.retrieveByName("aaron_johnson0"); +var userByName = client.users().getByName("aaron_johnson0"); // Get by name with fields -var user = Users.retrieveByName( +var userByNameWithFields = client.users().getByName( "aaron_johnson0", - "teams,roles,domains" -); + "teams,roles,domains"); ``` ```bash GET /v1/users/{id} diff --git a/v2.0.x/api-reference/teams-and-users/users/update.mdx b/v2.0.x/api-reference/teams-and-users/users/update.mdx index ff7fbba4b..9cfd2eb85 100644 --- a/v2.0.x/api-reference/teams-and-users/users/update.mdx +++ b/v2.0.x/api-reference/teams-and-users/users/update.mdx @@ -26,7 +26,7 @@ Adding a user to a closed team (`isJoinable: false`) requires an administrator. Use `PATCH /v1/users/name/{fqn}` to update by fully qualified name. - Fully qualified name of the user (e.g., `aaron_johnson0`). + Fully qualified name of the user, for example `aaron_johnson0`. ## Body Parameters @@ -77,8 +77,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -101,16 +101,16 @@ user.description = "Senior data analyst in the Sales team" user.displayName = "Aaron M. Johnson" updated = Users.update(user) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/users/{id} -import static org.openmetadata.sdk.fluent.Users.*; - -// Retrieve, modify, and update -var user = Users.retrieve("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); +// client is an initialized OpenMetadataClient. +var userId = "77655e6e-ad33-49da-bbca-db4ba4d4e2cd"; +var user = client.users().get(userId); user.setDescription("Senior data analyst in the Sales team"); -var updated = Users.update(user); + +var updated = client.users().update(userId, user); ``` ```bash PATCH /v1/users/{id} diff --git a/v2.0.x/api-reference/teams-and-users/users/versions.mdx b/v2.0.x/api-reference/teams-and-users/users/versions.mdx index 7200919f2..0e1ebf62d 100644 --- a/v2.0.x/api-reference/teams-and-users/users/versions.mdx +++ b/v2.0.x/api-reference/teams-and-users/users/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/users/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/users/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Users @@ -40,7 +42,8 @@ configure( # List all versions versions = Users.get_versions("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version user_v1 = Users.get_specific_version( @@ -51,20 +54,17 @@ print(f"Original display name: {user_v1.displayName}") ``` ```java GET /v1/users/{id}/versions -import static org.openmetadata.sdk.fluent.Users.*; +// client is an initialized OpenMetadataClient. +var id = "77655e6e-ad33-49da-bbca-db4ba4d4e2cd"; // List all versions -var history = Users.getVersions("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); - +var history = client.users().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Users.getSpecificVersion( - "77655e6e-ad33-49da-bbca-db4ba4d4e2cd", - 0.1 -); +var v1 = client.users().getVersion(id, 0.1); System.out.println("Display Name: " + v1.getDisplayName()); ``` diff --git a/v2.0.x/connectors/ingestion/deployment.mdx b/v2.0.x/connectors/ingestion/deployment.mdx index f38537d92..877d8d077 100644 --- a/v2.0.x/connectors/ingestion/deployment.mdx +++ b/v2.0.x/connectors/ingestion/deployment.mdx @@ -277,14 +277,15 @@ it will be the [AirflowRESTClient](https://github.com/open-metadata/OpenMetadata First, let's see what it is needed to instantiate the Airflow REST Client: ```java -public AirflowRESTClient(AirflowConfiguration airflowConfig) { - super( - airflowConfig.getUsername(), - airflowConfig.getPassword(), - airflowConfig.getApiEndpoint(), - airflowConfig.getHostIp(), - airflowConfig.getTimeout()); - } +public AirflowRESTClient(PipelineServiceClientConfiguration config) throws KeyStoreException { + super(config); + ... + this.username = getStringParam(params, USERNAME_KEY); + this.password = getStringParam(params, PASSWORD_KEY); + ... + this.serviceURL = validateServiceURL(config.getApiEndpoint()); + ... +} ``` If we focus on the important properties here, we can see: diff --git a/v2.0.x/deployment/secrets-manager/how-to-add-a-new-implementation.mdx b/v2.0.x/deployment/secrets-manager/how-to-add-a-new-implementation.mdx index 6f52295b8..1ae5ab4c0 100644 --- a/v2.0.x/deployment/secrets-manager/how-to-add-a-new-implementation.mdx +++ b/v2.0.x/deployment/secrets-manager/how-to-add-a-new-implementation.mdx @@ -32,22 +32,43 @@ You can find [this](https://github.com/open-metadata/OpenMetadata/blob/main/open Once we have updated the JSON Schema, we can start implementing our Secrets Manager, extending the `ExternalSecretsManager.java` abstract class located [here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-service/src/main/java/org/openmetadata/service/secrets/ExternalSecretsManager.java). For example: ```java -public abstract class AwesomeSecretsManager extends ExternalSecretsManager { +public class AwesomeSecretsManager extends ExternalSecretsManager { - protected AwesomeSecretsManager(String clusterPrefix) { - super(SecretsManagerProvider.AWESOME_SM, clusterPrefix); + private static AwesomeSecretsManager instance = null; + + private AwesomeSecretsManager(SecretsConfig secretsConfig) { + super(SecretsManagerProvider.AWESOME_SM, secretsConfig); } + @Override void storeSecret(String secretName, String secretValue) { // your implementation } + + @Override void updateSecret(String secretName, String secretValue) { // your implementation } + @Override String getSecret(String secretName) { // your implementation } + + @Override + protected void deleteSecretInternal(String secretName) { + // your implementation + } + + @Override + protected boolean isNotFoundException(Exception exception) { + // your implementation + } + + public static AwesomeSecretsManager getInstance(SecretsConfig secretsConfig) { + if (instance == null) instance = new AwesomeSecretsManager(secretsConfig); + return instance; + } } ``` @@ -55,8 +76,7 @@ After this, we can update `SecretsManagerFactory.java` which is a factory class. ```java ... - case AWESOME_SM: - return AwesomeSecretsManager.getInstance(config, clusterName); + case AWESOME_SM -> secretsManager = AwesomeSecretsManager.getInstance(secretsConfig); ... ``` diff --git a/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx b/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx index a5ad4287a..721fb46cf 100644 --- a/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx +++ b/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx @@ -12,7 +12,8 @@ For large datasets that don't fit in memory, validate data in chunks: ```python import pandas as pd -from metadata.sdk.data_quality.dataframes.dataframe_validator import DataFrameValidator, ValidationResult +from metadata.sdk.data_quality.dataframes.dataframe_validator import DataFrameValidator +from metadata.sdk.data_quality.dataframes.validation_results import ValidationResult validator = DataFrameValidator() validator.add_openmetadata_table_tests("Postgres.warehouse.staging.transactions") @@ -144,7 +145,7 @@ print(f"Validation {'succeeded' if result.success else 'failed'}") As of version 1.11.0.0 of the SDK, DataFrameValidator supports only one failure mode: short circuit. ```python -from metadata.sdk.data_quality.dataframes import FailureMode +from metadata.sdk.data_quality.dataframes.validation_results import FailureMode # SHORT_CIRCUIT (default): Stop on first test failure result = validator.validate(df, mode=FailureMode.SHORT_CIRCUIT) @@ -181,7 +182,7 @@ for test_case, test_result in result.test_cases_and_results: ### Merging Results from Multiple Chunks ```python -from metadata.sdk.data_quality.dataframes import ValidationResult +from metadata.sdk.data_quality.dataframes.validation_results import ValidationResult results = [] diff --git a/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx b/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx index 74baf671b..7455e1904 100644 --- a/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx +++ b/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx @@ -79,7 +79,7 @@ if result.success: else: print("✗ Validation failed") for test_case, test_result in result.test_cases_and_results: - if test_result.testCaseStatus != "Success": + if test_result.testCaseStatus.value != "Success": print(f" - {test_case.name.root}: {test_result.result}") ``` diff --git a/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx b/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx index 69567fd5c..63f2628c5 100644 --- a/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx +++ b/v2.0.x/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx @@ -406,7 +406,7 @@ If you experience connection timeouts, verify: If you encounter import errors: -```python +```text ModuleNotFoundError: No module named 'metadata' ``` diff --git a/v2.0.x/sdk/ai-sdk.mdx b/v2.0.x/sdk/ai-sdk.mdx index 5069babc0..14013639f 100644 --- a/v2.0.x/sdk/ai-sdk.mdx +++ b/v2.0.x/sdk/ai-sdk.mdx @@ -92,7 +92,7 @@ const client = new AISdk({ ```java Java import io.openmetadata.ai.AISdk; -AISdk client = new AISdk.Builder() +AISdk client = AISdk.builder() .host("https://your-openmetadata-instance.com") .token("your-bot-jwt-token") .build(); @@ -144,7 +144,7 @@ console.log(`Created persona: ${persona.name}`); import io.openmetadata.ai.models.CreatePersonaRequest; import io.openmetadata.ai.models.PersonaInfo; -CreatePersonaRequest request = new CreatePersonaRequest.Builder() +CreatePersonaRequest request = CreatePersonaRequest.builder() .name("DataAnalyst") .description("A meticulous data analyst focused on data quality") .prompt("You are an expert data analyst working with OpenMetadata. " @@ -153,7 +153,7 @@ CreatePersonaRequest request = new CreatePersonaRequest.Builder() .displayName("Data Analyst") .build(); -PersonaInfo persona = client.createPersona(request); +PersonaInfo persona = client.personas().create(request); System.out.println("Created persona: " + persona.getName()); ``` @@ -187,7 +187,10 @@ for (const persona of personas) { ``` ```java Java -List personas = client.listPersonas(); +import io.openmetadata.ai.models.PersonaInfo; +import java.util.List; + +List personas = client.personas().list(); for (PersonaInfo persona : personas) { System.out.println(persona.getName() + ": " + persona.getDescription()); } @@ -248,23 +251,24 @@ console.log(`Created agent: ${agent.name}`); ``` ```java Java -import io.openmetadata.ai.models.CreateAgentRequest; import io.openmetadata.ai.models.AgentInfo; +import io.openmetadata.ai.models.CreateAgentRequest; +import java.util.List; -CreateAgentRequest request = new CreateAgentRequest.Builder() +// Pass the builder to create(); don't call build() +CreateAgentRequest.Builder request = CreateAgentRequest.builder() .name("DataQualityPlannerAgent") .description("Analyzes tables and recommends data quality tests") .persona("DataAnalyst") .displayName("Data Quality Planner") .apiEnabled(true) - .abilities(List.of( + .skills(List.of( "search_metadata", "get_entity_details", "get_entity_lineage" - )) - .build(); + )); -AgentInfo agent = client.createAgent(request); +AgentInfo agent = client.agents().create(request); System.out.println("Created agent: " + agent.getName()); ``` @@ -279,7 +283,7 @@ System.out.println("Created agent: " + agent.getName()); | `persona` | string | Yes | Name of an existing persona | | `display_name` | string | No | Human-readable name (defaults to `name`) | | `api_enabled` | boolean | No | Must be `true` for SDK invocation (default: `false`) | -| `abilities` | array | No | Allowed MCP tool names (all tools if omitted) | +| `abilities` | array | No | Allowed MCP tool names (all tools if omitted). In the Java SDK, the builder method is `skills`. | | `prompt` | string | No | Additional system prompt appended to persona's base prompt | | `provider` | string | No | LLM provider: `openai`, `anthropic`, `azure_openai` (default: `openai`) | | `bot_name` | string | No | OpenMetadata bot for metadata operations | @@ -306,7 +310,10 @@ for (const agent of agents) { ``` ```java Java -List agents = client.listAgents(); +import io.openmetadata.ai.models.AgentInfo; +import java.util.List; + +List agents = client.agents().list(); for (AgentInfo agent : agents) { System.out.println(agent.getName() + ": " + agent.getDescription()); } @@ -341,8 +348,10 @@ console.log(`Tools used: ${response.toolsUsed}`); ``` ```java Java +import io.openmetadata.ai.models.InvokeResponse; + InvokeResponse response = client.agent("DataQualityPlannerAgent") - .call("What data quality tests should I add for the customers table?"); + .invoke("What data quality tests should I add for the customers table?"); System.out.println(response.getResponse()); ``` @@ -398,12 +407,12 @@ for await (const event of client.agent('DataQualityPlannerAgent').stream( ```java Java client.agent("DataQualityPlannerAgent") - .stream("Analyze the orders table") - .forEach(event -> { + .stream("Analyze the orders table", event -> { switch (event.getType()) { - case "content" -> System.out.print(event.getContent()); - case "tool_use" -> System.out.println("\n[Using: " + event.getToolName() + "]"); - case "end" -> System.out.println("\nDone!"); + case CONTENT -> System.out.print(event.getContent()); + case TOOL_USE -> System.out.println("\n[Using: " + event.getToolName() + "]"); + case END -> System.out.println("\nDone!"); + default -> { } } }); ``` diff --git a/v2.0.x/sdk/go.mdx b/v2.0.x/sdk/go.mdx index 0b60e1b04..4cb52c437 100644 --- a/v2.0.x/sdk/go.mdx +++ b/v2.0.x/sdk/go.mdx @@ -25,20 +25,32 @@ go get github.com/open-metadata/openmetadata-sdk/openmetadata-go-client ## Create a Client -To interact with the OpenMetadata API, create a `Client` by providing the server URL and a JWT token for authentication: +To interact with the OpenMetadata API, create a `Client` by providing the server URL and a JWT token for authentication. Pass the server address without the `/api` suffix (for example `http://localhost:8585`). The client adds `/api/v1` itself. ```go package main import ( + "context" + "fmt" + "log" + "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" ) func main() { + ctx := context.Background() client := ometa.NewClient( "http://localhost:8585", ometa.WithToken(""), ) + + for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Name) + } } ``` @@ -56,6 +68,8 @@ You can customize the client behavior using functional options: Requests that return HTTP `429` (Too Many Requests) or `504` (Gateway Timeout) are automatically retried. ```go +import "time" + client := ometa.NewClient( "http://localhost:8585", ometa.WithToken(""), @@ -92,6 +106,8 @@ Every service provides the following methods: The `List` method returns a Go iterator that handles pagination automatically: ```go +ctx := context.Background() + for table, err := range client.Tables.List(ctx, nil) { if err != nil { log.Fatal(err) @@ -106,10 +122,10 @@ Retrieve a single entity by UUID or by Fully Qualified Name: ```go // By ID -table, err := client.Tables.GetByID(ctx, "", nil) +tableByID, err := client.Tables.GetByID(ctx, "", nil) // By Fully Qualified Name -table, err := client.Tables.GetByName(ctx, "sample_data.ecommerce_db.shopify.dim_customer", nil) +tableByName, err := client.Tables.GetByName(ctx, "sample_data.ecommerce_db.shopify.dim_customer", nil) ``` ### Create an Entity @@ -161,7 +177,7 @@ Delete by UUID or by Fully Qualified Name: err := client.Tables.Delete(ctx, "", nil) // By Fully Qualified Name with hard delete -err := client.Tables.DeleteByName(ctx, "sample_data.ecommerce_db.shopify.my_table", +err = client.Tables.DeleteByName(ctx, "sample_data.ecommerce_db.shopify.my_table", &ometa.DeleteTable1Params{HardDelete: ometa.Bool(true)}, ) ``` @@ -181,8 +197,9 @@ table, err := client.Tables.GetVersion(ctx, "", "0.2") ### Restore a Soft-Deleted Entity ```go -table, err := client.Tables.Restore(ctx, &ometa.RestoreEntity{ - Id: ometa.Str(""), +// table is a *ometa.Table you retrieved earlier +restored, err := client.Tables.Restore(ctx, &ometa.RestoreEntity{ + Id: table.Id, }) ``` diff --git a/v2.0.x/sdk/java.mdx b/v2.0.x/sdk/java.mdx index 2e45ee68a..ebbf5d4e6 100644 --- a/v2.0.x/sdk/java.mdx +++ b/v2.0.x/sdk/java.mdx @@ -24,204 +24,148 @@ You can add the below Maven Dependency for the OpenMetadata Java SDK. ``` -## Establish OpenMetadata Server Connection +## Connect to the OpenMetadata Server -To create OpenMetadata Gateway, you will need to establish a connection with *OpenMetadata Server*. The following -inputs will be needed for the same. -* Host Port: The url on which your instance of OpenMetadata is up and running. -* ApiVersion: The value will be "v1". -* Auth Provider: Provide the auth provider with which you need to configure. -* Security Config: Provide the config for the selected auth provider. +To connect to your OpenMetadata server, you need: -```java -OpenMetadataConnection server = new OpenMetadataConnection(); -server.setHostPort("http://localhost:{port}}/api"); -server.setApiVersion("v1"); -server.setAuthProvider(OpenMetadataConnection.AuthProvider.{auth_provider}); -server.setSecurityConfig({security_client_config}); -``` - -## Create OpenMetadata Gateway - -Once the connection details are provided, you can create an OpenMetadata Gateway -using the following piece of code. +* Server URL: The URL where your OpenMetadata instance is running, ending in `/api`. For example, `http://localhost:8585/api`. +* Access token: A JSON Web Token (JWT) for a user or bot. See [Authentication](/v2.0.x/api-reference/authentication) to learn how to get one. ```java -// OpenMetadata Gateway -OpenMetadata openMetadataGateway = new OpenMetadata(server); -``` +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -## Use Java SDK without Authentication -To use the Java SDK without any authentication, you can use `NoOpAuthenticationProvider.java`. \ +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .build(); -```java -NoOpAuthenticationProvider noOpAuthenticationProvider = new NoOpAuthenticationProvider(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` -Establish the [OpenMetadata Server Connection](#establish-openmetadata-server-connection) and provide `noOpAuthenticationProvider` in the config. +Tune the connection with these options. Timeouts are in milliseconds, and `header` adds a custom header to every request: ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.NO_AUTH); +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .connectTimeout(10000) + .readTimeout(30000) + .header("X-Request-Source", "my-app") + .build(); ``` -## Use Java SDK with Authentication. +## Authenticate with a JWT Token -The OpenMetadata Java SDK supports several auth providers: -* [Google](#google) -* [Okta](#okta) -* [Auth0](#auth0) -* [Azure](#azure) -* [OpenMetadata](#openmetadata) +The Java SDK authenticates with a JWT access token that you pass to `accessToken(...)`. This is the same for every sign-in method on your OpenMetadata server, including Google, Okta, Auth0, Azure, and custom OpenID Connect (OIDC). Generate a bot token or a personal access token in OpenMetadata and use it here. -Apart from the above mentioned auth providers, OpenMetadata Java SDK also supports [Custom OIDC](#custom-oidc). +If your server doesn't require authentication, leave out `accessToken(...)`. -### Google -To set up Google as the auth provider, the following details are required: -* Secret Key: Pass the JSON file generated in [Create Service Account](/v2.0.x/deployment/security/google) as the secretKey. +## Use the Fluent API -```java -GoogleSSOClientConfig googleSSOClientConfig = new GoogleSSOClientConfig(); -ssoConfig.setAudience("https://www.googleapis.com/oauth2/v4/token"); -ssoConfig.setSecretKey("{secret_key.json}"); -``` +The fluent classes, such as `Tables`, `Users`, and `Teams`, work with a default client. Register your client once with `OM.init`, and the fluent classes use it: -Provide the Google config while creating the [server connection](#establish-openmetadata-server-connection). ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.GOOGLE); -server.setSecurityConfig(googleSSOClientConfig); +import org.openmetadata.sdk.OM; +import org.openmetadata.sdk.fluent.Tables; -``` +OM.init(client); -### Okta -To set up Okta as the auth provider, the following details should be provided: -* Client ID: Provide the client ID for the service application -* Org URL: It is the same as the ISSUER_URL with v1/token. It is recommended to use a separate authorization server for different applications, rather than using the default authorization server. -* Private Key: Use the Public/Private Key Pair that was generated while [Creating the Service Application](/v2.0.x/deployment/security/okta#okta-sso). When copy-pasting the keys ensure that there are no additional codes and that it is a JSON compatible string. -* Email: Enter the email address -* Scopes: Add the details of the scope created in the Authorization Server. Enter the name of the default scope created. +// Find a table by its fully qualified name +var table = Tables.findByName("mysql-prod.employees.public.employees") + .includeOwners() + .includeTags() + .fetch() + .get(); -```java -OktaSSOClientConfig oktaSSOClientConfig = new OktaSSOClientConfig(); -oktaSSOClientConfig.setClientId("{client_id}"); -oktaSSOClientConfig.setOrgURL("{org_url}/v1/token"); -oktaSSOClientConfig.setPrivateKey("{public/private keypair}"); -oktaSSOClientConfig.setEmail("{email}"); -oktaSSOClientConfig.setScopes({scope_list}); +// Update its description +Tables.findByName("mysql-prod.employees.public.employees") + .fetch() + .withDescription("Updated description") + .save(); ``` -Provide the Okta config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OKTA); -server.setSecurityConfig(oktaSSOClientConfig); -``` +## Use the Service Clients -### Auth0 -To set up Auth0 as the auth provider, the following details are required: -* Client ID: Provide the client ID for the service application -* Secret Key: Provide the client secret. -* Domain: Provide the Auth0 domain. For example `test.us.auth0.com` +Every entity type has a service on the client, such as `client.tables()`, `client.users()`, and `client.dashboards()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. Below are some examples: ```java -Auth0SSOClientConfig auth0SSOClientConfig = new Auth0SSOClientConfig(); -auth0SSOClientConfig.setClientId("{client_id}"); -auth0SSOClientConfig.setSecretKey("{secret_key}"); -auth0SSOClientConfig.setDomain("{domain}"); -``` -Provide the Auth0 config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AUTH_0); -server.setSecurityConfig(auth0SSOClientConfig); -``` +import org.openmetadata.sdk.models.ListParams; -### Azure -To set up Azure as the auth provider, the following details should be provided: -* Client ID: The Application (Client) ID is displayed in the Overview section of the registered application. -* Client Secret: The clientSecret can be accessed from the Certificates & secret section of the application. -* Authority: Use your Microsoft Entra tenant authority. See [Microsoft's OpenID Connect documentation](https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc) for the endpoint format. -* Scopes: Add the details of the scope created. +// Tables +var tables = client.tables().list(new ListParams().setLimit(10)); +for (var table : tables.getData()) { + System.out.println(table.getFullyQualifiedName()); +} -```java -AzureSSOClientConfig azureSSOClientConfig = new AzureSSOClientConfig(); -azureSSOClientConfig.setClientId("{client_id}"); -azureSSOClientConfig.setClientSecret("{client_secret}"); -azureSSOClientConfig.setAuthority("{authority}"); -azureSSOClientConfig.setScopes({scope_list}); -``` -Provide the Azure config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AZURE); -server.setSecurityConfig(azureSSOClientConfig); +// Users +var users = client.users().list(new ListParams().setLimit(10)); + +// Dashboards +var dashboards = client.dashboards().list(new ListParams().setLimit(10)); ``` -### OpenMetadata -To set up OpenMetadata as the auth provider, the following details should be provided: -* JWT Token: Provide the JWT Token. For example `eyJraWQiOiJHYjM4OWEtOWY3Ni1nZGpzLWE5Mmo....XN0aW9uLWJvdEBvcGVubWV0YWRhdGEub3JnIn0.Ku_FHGIS3Id3ARusMaXZDYKcq...Ztap9KDU7nZilNT2Bq-o75aIsgKKmtSuVdBTzpFK8aLGLmRp_8J007t-kpcjIW7Qf0l4...dGb0QqhoZin0JA` +The following examples show how to call an API: + +* Create a table ```java -OpenMetadataJWTClientConfig openMetadataJWTClientConfig = new OpenMetadataJWTClientConfig(); -openMetadataJWTClientConfig.setJwtToken("{jwt_token}"); -``` -Provide the OpenMetadata config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OPENMETADATA); -server.setSecurityConfig(openMetadataJWTClientConfig); -``` +import java.util.List; +import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; -### Custom OIDC -To set up Custom auth provider. The following details are required: -* Client ID: Provide the client ID of the preferred auth provider -* Client Secret: Provide the client secret of your preferred auth provider -* Token Endpoint: Provide the token endpoint of your preferred auth provider +CreateTable request = new CreateTable() + .withName("orders") + .withDatabaseSchema("mysql-prod.employees.public") + .withDescription("Orders placed by customers") + .withColumns(List.of( + new Column() + .withName("order_id") + .withDataType(ColumnDataType.BIGINT) + .withDescription("Primary key"), + new Column() + .withName("status") + .withDataType(ColumnDataType.VARCHAR) + .withDataLength(50))); -```java -CustomOIDCSSOClientConfig customOIDCSSOClientConfig = new CustomOIDCSSOClientConfig(); -config.setClientId("{client_id}"); -config.setSecretKey("{client_secret}"); -config.setTokenEndpoint("{token_endpoint}"); +var table = client.tables().create(request); ``` -Provide the custom auth provider config while creating the [server connection](#establish-openmetadata-server-connection). +* Get a table by fully qualified name + ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.CUSTOM_OIDC); -server.setSecurityConfig(customOIDCSSOClientConfig); +var table = client.tables().getByName("mysql-prod.employees.public.employees", "columns,owners"); ``` -## How to Use APIs Using the Java SDK -You can use an API from the [OpenMetadata Gateway](#create-openmetadata-gateway). -Using OpenMetadata Gateway, you will need to build the client by providing the `class` of the respected API. -Below are some examples: +* Search + ```java -// Dashboards API -DashboardsApi dashboardApi = openMetadataGateway.buildClient(DashboardsApi.class); +String response = client.search() + .query("customer") + .index("table_search_index") + .size(10) + .execute(); +``` -// Tables API -TablesApi tablesApiClient = openMetadataGateway.buildClient(TablesApi.class); +The search call returns the raw JSON response from the server as a string. -// Users API -UsersApi usersApi = openMetadataGateway.buildClient(UsersApi.class); +## Handle Errors -// Locations API -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -``` +When the server returns an error, the SDK throws an `OpenMetadataException`. Use `getStatusCode()` to see which error it was: -Please refer to the examples to access an API: -* Tables API ```java -TablesApi tablesApi = openMetadataGateway.buildClient(TablesApi.class); -tablesApi.addLocationToTable("{table_id}", "{location_id}"); -``` -* Location API -```java -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -CreateLocation createLocation = new CreateLocation(); -Location location = locationsApi.createLocation(createLocation); -``` +import org.openmetadata.sdk.exceptions.OpenMetadataException; -* Elastic Search API -```java -ElasticSearchApi esApi = openMetadataGateway.buildClient(ElasticSearchApi.class); -Response response = esApi.searchEntitiesWithQuery("", "pipeline_search_index", false, 0, 0, null, null, true, "{\"query\":{\"bool\":{}}}", null, false, null ); -String data = IOUtils.toString(response.body().asInputStream(), Charsets.UTF_8); +try { + var table = client.tables().getByName("mysql-prod.employees.public.missing"); +} catch (OpenMetadataException e) { + if (e.getStatusCode() == 404) { + System.out.println("Table not found"); + } else { + System.out.println("Request failed: " + e.getMessage()); + } +} ``` ## More examples diff --git a/v2.0.x/sdk/java/info.mdx b/v2.0.x/sdk/java/info.mdx index b81f01cc0..30ed55c66 100644 --- a/v2.0.x/sdk/java/info.mdx +++ b/v2.0.x/sdk/java/info.mdx @@ -6,7 +6,7 @@ sidebarTitle: Java SDK Info # Java SDK -The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers comprehensive support for entity management, authentication, and integration with enterprise Java applications. +The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers support for entity management, search, lineage, and authentication with a JWT token. ## Installation @@ -35,85 +35,87 @@ implementation 'org.open-metadata:openmetadata-sdk:2.0.5' ### Basic Connection ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; -import org.openmetadata.client.auth.BasicAuthProvider; - -// Create client with basic authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new BasicAuthProvider("admin", "admin")) +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.network.HttpMethod; + +// Create a client with a JWT token +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") .build(); -// Health check -if (client.healthCheck()) { - System.out.println("Successfully connected to OpenMetadata!"); -} -``` - -### JWT Authentication - -```java -import org.openmetadata.client.auth.JWTAuthProvider; +OpenMetadataClient client = new OpenMetadataClient(config); -// Create client with JWT authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new JWTAuthProvider("your-jwt-token")) - .build(); +// Check the connection by reading the server version +String version = client.getHttpClient() + .executeForString(HttpMethod.GET, "/v1/system/version", null); +System.out.println("Connected to OpenMetadata: " + version); ``` +For more information about getting a token, see [Authentication](/v2.0.x/api-reference/authentication). + ## Core Functionality ### Working with Entities +Every entity type has a service on the client, such as `client.databaseServices()`, `client.tables()`, and `client.users()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. + #### Database Services ```java -import org.openmetadata.schema.entity.services.DatabaseService; import org.openmetadata.schema.api.services.CreateDatabaseService; +import org.openmetadata.schema.api.services.DatabaseConnection; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.services.connections.database.MysqlConnection; +import org.openmetadata.sdk.models.ListParams; -// List all database services -List services = client.listDatabaseServices(); -System.out.println("Found " + services.size() + " database services"); +// List database services +var services = client.databaseServices().list(new ListParams().setLimit(50)); +System.out.println("Found " + services.getData().size() + " database services"); // Get specific service by name -DatabaseService service = client.getDatabaseServiceByName("mysql-prod"); +DatabaseService service = client.databaseServices().getByName("mysql-prod"); // Create new database service CreateDatabaseService createRequest = new CreateDatabaseService() .withName("new-mysql-service") - .withServiceType(DatabaseServiceType.MYSQL) - .withDescription("Production MySQL database"); - -DatabaseService newService = client.createDatabaseService(createRequest); + .withServiceType(CreateDatabaseService.DatabaseServiceType.Mysql) + .withDescription("Production MySQL database") + .withConnection(new DatabaseConnection().withConfig( + new MysqlConnection() + .withHostPort("localhost:3306") + .withUsername("openmetadata_user"))); + +DatabaseService newService = client.databaseServices().create(createRequest); ``` #### Tables ```java -import org.openmetadata.schema.entity.data.Table; +import java.util.List; import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; +import org.openmetadata.sdk.models.ListParams; // Get table by fully qualified name -Table table = client.getTableByName("mysql-prod.employees.employees"); -if (table != null) { - System.out.println("Table: " + table.getName()); - System.out.println("Columns: " + table.getColumns().size()); -} +Table table = client.tables().getByName("mysql-prod.employees.public.employees", "columns"); +System.out.println("Table: " + table.getName()); +System.out.println("Columns: " + table.getColumns().size()); -// List tables with pagination -EntityList
tables = client.listTables( - 10, // limit - null, // after cursor - "mysql-prod" // service filter -); +// List tables in a schema with pagination +var tables = client.tables().list( + new ListParams() + .setLimit(10) + .addFilter("databaseSchema", "mysql-prod.employees.public")); // Create table CreateTable createTable = new CreateTable() .withName("new_table") - .withDatabaseSchema("mysql-prod.employees") - .withColumns(Arrays.asList( + .withDatabaseSchema("mysql-prod.employees.public") + .withColumns(List.of( new Column() .withName("id") .withDataType(ColumnDataType.BIGINT) @@ -125,7 +127,7 @@ CreateTable createTable = new CreateTable() .withDescription("Employee name") )); -Table newTable = client.createTable(createTable); +Table newTable = client.tables().create(createTable); ``` ### Entity Operations @@ -133,111 +135,83 @@ Table newTable = client.createTable(createTable); #### CRUD Operations ```java -// Create or Update -DatabaseService service = client.createOrUpdateDatabaseService(createRequest); +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.network.HttpMethod; + +// Create or update a table +Table table = client.tables().createOrUpdate(createTable); + +// Create or update a database service +DatabaseService service = client.getHttpClient().execute( + HttpMethod.PUT, "/v1/services/databaseServices", createRequest, DatabaseService.class); // Get by ID -UUID serviceId = UUID.fromString("service-uuid-here"); -DatabaseService service = client.getDatabaseServiceById(serviceId); +UUID serviceId = service.getId(); +DatabaseService sameService = client.databaseServices().get(serviceId); // Delete -client.deleteDatabaseService(serviceId, false); // soft delete -client.deleteDatabaseService(serviceId, true); // hard delete +client.databaseServices().delete(serviceId.toString()); // soft delete +client.databaseServices().delete(serviceId.toString(), Map.of("hardDelete", "true")); // hard delete ``` #### Search and Filtering ```java -// Search tables -SearchRequest searchRequest = new SearchRequest() - .withQuery("customer") - .withEntityTypes(Arrays.asList("table")) - .withSize(50); - -SearchResponse results = client.search(searchRequest); -for (SearchHit hit : results.getHits()) { - System.out.println("Found: " + hit.getDisplayName()); -} +import org.openmetadata.sdk.models.ListParams; + +// Search tables. The response is the raw JSON from the server. +String results = client.search() + .query("customer") + .index("table_search_index") + .size(50) + .execute(); +System.out.println(results); // Advanced filtering -EntityList
customerTables = client.listTables( - 100, - null, - Map.of( - "service", "mysql-prod", - "database", "ecommerce" - ) -); +var customerTables = client.tables().list( + new ListParams() + .setLimit(100) + .addFilter("database", "mysql-prod.ecommerce")); ``` ## Advanced Features -### Authentication Providers - -#### Custom Authentication - -```java -import org.openmetadata.client.auth.AuthProvider; - -public class CustomAuthProvider implements AuthProvider { - private String customToken; - - public CustomAuthProvider(String token) { - this.customToken = token; - } - - @Override - public String getAuthToken() { - return "Bearer " + customToken; - } - - @Override - public void refresh() { - // Implement token refresh logic - } -} - -// Use custom auth provider -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(new CustomAuthProvider("custom-token")) - .build(); -``` +### Authentication -#### OAuth 2.0 Integration +The Java SDK authenticates with a JWT access token. When your token changes, create a new client with the new token: ```java -import org.openmetadata.client.auth.OAuth2AuthProvider; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -OAuth2AuthProvider authProvider = OAuth2AuthProvider.builder() - .clientId("your-client-id") - .clientSecret("your-client-secret") - .tokenUrl("https://auth.provider.com/oauth/token") - .scopes(Arrays.asList("read", "write")) - .build(); +String newToken = "your-new-jwt-token"; -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(authProvider) - .build(); +OpenMetadataClient client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl("https://your-instance.com/api") + .accessToken(newToken) + .build()); ``` ### Error Handling ```java -import org.openmetadata.client.exception.OpenMetadataException; +import org.openmetadata.sdk.exceptions.OpenMetadataException; try { - Table table = client.getTableByName("non-existent-table"); + var table = client.tables().getByName("non-existent-table"); } catch (OpenMetadataException e) { - switch (e.getErrorCode()) { - case NOT_FOUND: + switch (e.getStatusCode()) { + case 404: System.out.println("Table not found"); break; - case UNAUTHORIZED: + case 401: System.out.println("Authentication failed"); break; - case FORBIDDEN: + case 403: System.out.println("Access denied"); break; default: @@ -248,15 +222,22 @@ try { ### Async Operations +The service methods are blocking. To run them in parallel, wrap them in a `CompletableFuture`: + ```java +import java.util.List; import java.util.concurrent.CompletableFuture; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.models.ListParams; -// Async client operations CompletableFuture> servicesFuture = - client.listDatabaseServicesAsync(); + CompletableFuture.supplyAsync( + () -> client.databaseServices().list(new ListParams().setLimit(50)).getData()); CompletableFuture
tableFuture = - client.getTableByNameAsync("mysql-prod.employees.employees"); + CompletableFuture.supplyAsync( + () -> client.tables().getByName("mysql-prod.employees.public.employees", "columns")); // Combine async operations CompletableFuture combinedFuture = CompletableFuture.allOf( @@ -280,39 +261,19 @@ CompletableFuture combinedFuture = CompletableFuture.allOf( ### Client Configuration ```java -import org.openmetadata.client.config.ClientConfig; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -ClientConfig config = ClientConfig.builder() - .connectionTimeout(30000) // 30 seconds +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .connectTimeout(30000) // 30 seconds .readTimeout(60000) // 60 seconds - .retryCount(3) // Retry failed requests 3 times - .enableLogging(true) // Enable request/response logging - .enableMetrics(true) // Enable client metrics - .userAgent("MyApp/1.0") // Custom user agent + .writeTimeout(60000) // 60 seconds + .header("User-Agent", "MyApp/1.0") // Custom header on every request .build(); -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(authProvider) - .config(config) - .build(); -``` - -### Connection Pooling - -```java -import org.openmetadata.client.config.ConnectionPoolConfig; - -ConnectionPoolConfig poolConfig = ConnectionPoolConfig.builder() - .maxTotal(100) // Maximum total connections - .maxPerRoute(20) // Maximum connections per route - .connectionTTL(300000) // Connection TTL in milliseconds - .validateAfterInactivity(10000) // Validate connections after 10s - .build(); - -ClientConfig config = ClientConfig.builder() - .connectionPoolConfig(poolConfig) - .build(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ## Common Use Cases @@ -320,15 +281,26 @@ ClientConfig config = ClientConfig.builder() ### Metadata Discovery ```java -// Discover all tables in a service -String serviceName = "mysql-prod"; +import java.util.ArrayList; +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + +// Discover all tables in a schema +String schemaName = "mysql-prod.employees.public"; List
allTables = new ArrayList<>(); String after = null; do { - EntityList
batch = client.listTables(100, after, serviceName); + var params = new ListParams() + .setLimit(100) + .addFilter("databaseSchema", schemaName); + if (after != null) { + params.setAfter(after); + } + var batch = client.tables().list(params); allTables.addAll(batch.getData()); - after = batch.getAfter(); + after = batch.getPaging().getAfter(); } while (after != null); System.out.println("Discovered " + allTables.size() + " tables"); @@ -337,17 +309,19 @@ System.out.println("Discovered " + allTables.size() + " tables"); ### Bulk Operations ```java +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + // Bulk update table descriptions -List
tables = client.listAllTablesInService("mysql-prod"); +List
tables = client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", "mysql-prod.employees.public")) + .getData(); for (Table table : tables) { if (table.getDescription() == null || table.getDescription().isEmpty()) { - CreateTable updateRequest = new CreateTable() - .withName(table.getName()) - .withDatabaseSchema(table.getDatabaseSchema().getFullyQualifiedName()) - .withDescription("Auto-generated description for " + table.getName()); - - client.createOrUpdateTable(updateRequest); + table.setDescription("Auto-generated description for " + table.getName()); + client.tables().update(table.getId().toString(), table); } } ``` @@ -355,87 +329,61 @@ for (Table table : tables) { ### Lineage Operations ```java -import org.openmetadata.schema.type.EntityLineage; - -// Get table lineage -EntityLineage lineage = client.getTableLineage( - "mysql-prod.employees.employees", - 1, // upstream depth - 1 // downstream depth +// Get table lineage as JSON (1 hop upstream, 1 hop downstream) +String lineage = client.lineage().getLineageByName( + "table", + "mysql-prod.employees.public.employees", + "1", // upstream depth + "1" // downstream depth ); -System.out.println("Upstream entities: " + lineage.getUpstreamEdges().size()); -System.out.println("Downstream entities: " + lineage.getDownstreamEdges().size()); +System.out.println(lineage); ``` -## Spring Boot Integration +For more information about the fluent API for lineage, see [Java SDK for Lineage](/v2.0.x/api-reference/sdk/java/lineage). -### Configuration Class +## Use the Client in Your Application -```java -@Configuration -@EnableConfigurationProperties(OpenMetadataProperties.class) -public class OpenMetadataConfig { - - @Bean - public OpenMetadataClient openMetadataClient(OpenMetadataProperties properties) { - return OpenMetadataClient.builder() - .baseUrl(properties.getBaseUrl()) - .authProvider(new JWTAuthProvider(properties.getJwtToken())) - .build(); - } -} - -@ConfigurationProperties(prefix = "openmetadata") -@Data -public class OpenMetadataProperties { - private String baseUrl; - private String jwtToken; -} -``` - -### Service Layer +Create one `OpenMetadataClient` and share it across your application. If you use a framework such as Spring Boot, register the client as a singleton bean. ```java -@Service -public class MetadataService { +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.models.ListParams; - private final OpenMetadataClient client; +class MetadataService { - public MetadataService(OpenMetadataClient client) { - this.client = client; - } + private final OpenMetadataClient client; - public List
getTablesForService(String serviceName) { - return client.listAllTablesInService(serviceName); + public MetadataService(String baseUrl, String jwtToken) { + this.client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl(baseUrl) + .accessToken(jwtToken) + .build()); } - public Table createTable(CreateTableRequest request) { - CreateTable createTable = new CreateTable() - .withName(request.getName()) - .withDatabaseSchema(request.getSchemaFqn()) - .withColumns(request.getColumns()); - - return client.createTable(createTable); + public java.util.List getTablesForSchema(String schemaFqn) { + return client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", schemaFqn)) + .getData(); } } ``` ## Best Practices -1. **Resource Management**: Always close clients when done -2. **Connection Pooling**: Use connection pooling for high-throughput applications -3. **Error Handling**: Implement proper retry logic and error handling -4. **Authentication**: Use secure authentication methods in production -5. **Async Operations**: Use async methods for better performance in concurrent scenarios -6. **Pagination**: Always handle pagination for large datasets -7. **Caching**: Implement caching for frequently accessed entities +- **Reuse the client**: Create one client and share it instead of creating a new one per request. +- **Handle errors**: Catch `OpenMetadataException` and check the status code. +- **Protect authentication**: Keep your JWT token in a secret store, not in source code. +- **Use async operations**: Wrap calls in `CompletableFuture` for better performance in concurrent scenarios. +- **Handle pagination**: Always handle pagination for large datasets. +- **Cache entities**: Implement caching for frequently accessed entities. ## Performance Tips -- Use batch operations when possible -- Implement connection pooling for high-concurrency applications -- Cache frequently accessed metadata -- Use async operations for better throughput -- Specify only required fields when fetching entities -- Implement proper retry strategies with exponential backoff \ No newline at end of file +- Create one client and reuse it. +- Cache frequently accessed metadata. +- Run independent calls in parallel with `CompletableFuture`. +- Specify only required fields when fetching entities. +- Use filters to narrow lists before you read them. diff --git a/v2.0.x/sdk/overview.mdx b/v2.0.x/sdk/overview.mdx index cefe8df4e..60d98fa1f 100644 --- a/v2.0.x/sdk/overview.mdx +++ b/v2.0.x/sdk/overview.mdx @@ -2,6 +2,8 @@ title: OpenMetadata SDKs description: 'Official client libraries for Python, Java, and Go to integrate with OpenMetadata APIs. Type-safe, full-featured SDKs for metadata management and automation.' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # OpenMetadata SDKs @@ -25,7 +27,7 @@ Official client libraries provide type-safe, full-featured access to OpenMetadat - Full-featured Python client + Original Client and SDK 2.0 (`metadata.sdk`) Enterprise Java integration @@ -44,15 +46,24 @@ Perfect for: - ML pipeline automation - Data quality automation +SDK 2.0 (`metadata.sdk`, OpenMetadata 1.10.0 and later): + + + +Original client: + ```python from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( OpenMetadataConnection, ) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) from metadata.ingestion.ometa.ometa_api import OpenMetadata server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -69,13 +80,15 @@ Perfect for: - Legacy system integration ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; + +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .build(); -OpenMetadataClient client = new OpenMetadataClient( - "http://localhost:8585/api", - "your-jwt-token" -); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ### Go SDK @@ -86,11 +99,11 @@ Perfect for: - High-performance services ```go -import "github.com/open-metadata/openmetadata-go-client" +import "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" -client := openmetadata.NewClient( - "http://localhost:8585/api", - "your-jwt-token", +client := ometa.NewClient( + "http://localhost:8585", + ometa.WithToken("your-jwt-token"), ) ``` diff --git a/v2.0.x/sdk/python.mdx b/v2.0.x/sdk/python.mdx index 024fc6394..ec48d9bbc 100644 --- a/v2.0.x/sdk/python.mdx +++ b/v2.0.x/sdk/python.mdx @@ -3,6 +3,8 @@ title: Python SDK | OpenMetadata Python SDK Documentation description: Master OpenMetadata'sPython SDK with comprehensive documentation, code examples, and API guides. Build powerful data discovery and governance solutions. sidebarTitle: Overview --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -17,7 +19,7 @@ We are now going to present a high-level Python API as a type-safe and gentle wr - Make sure to use the same `openmetadata-ingestion` version as your server version. For example, if you have the OpenMetadata server at version 2.0.5, you need to install: -```python +```bash pip install "openmetadata-ingestion~=2.0.5.0" ``` @@ -30,7 +32,15 @@ In the [OpenMetadata Design](/v2.0.x/developers/architecture), we have been diss This means that whenever we need to interact with the metadata system or develop a new connector or logic, we have to make sure that we pass the proper inputs and handle the types of outputs. -## Introducing the Python API + + +## SDK 2.0 Quick Start + +Connect with `configure()`, then create, update, and delete a table: + + + +## Introducing the Python API (Original Client) Let's suppose that we have our local OpenMetadata server running at `http:localhost:8585`. We can play with it with simple `cURL` or `httpie` commands, and if we just want to take a look at the Entity instances we have lying around, that might probably be enough. However, let's imagine that we want to create or update an ML Model Entity with a `PUT`. To do so, we need to make sure that we are providing a proper JSON, covering all the attributes and types required by the Entity definition. @@ -320,8 +330,8 @@ class CreateDatabaseRequest(BaseModel): None, description='Description of the database instance. What it has and how to use it.', ) - owner: Optional[entityReference.EntityReference] = Field( - None, description='Owner of this database' + owners: Optional[entityReferenceList.EntityReferenceList] = Field( + None, description='Owners of this database' ) service: basic.FullyQualifiedEntityName = Field( ..., @@ -335,7 +345,7 @@ class CreateDatabaseRequest(BaseModel): Note how the only non-optional fields are `name` and `service`. The type of `service`, however, is `FullyQualifiedEntityName`. This is expected, as there we need to pass the information of an existing Entity. In our case, the `fullyQualifiedName` of the `DatabaseService` we just created. -In the case of the `owner` field, repeating the exercise and reviewing the required fields to instantiate an `EntityReference` we notice how we need to pass an `id: uuid.UUID` and `type: str`. There we need to specify the `id` and `type` of an `User`. +The `owners` field takes a list of `EntityReference`. To instantiate an `EntityReference`, pass an `id: uuid.UUID` and `type: str`. Specify the `id` and `type` of a `User`. **Querying by name** @@ -404,8 +414,8 @@ Let's now update the `Table` by adding an owner. This will require us to create First, make sure that no owner has been set during the creation: ```python -print(table_entity.owner) -# None +print(table_entity.owners) +# root=[] ``` Now, create a `User`: @@ -418,19 +428,19 @@ user = metadata.create_or_update( ) ``` -Update our instance of `create_table` to add the `owner` field (we need to use the `Create` class as we'll run a `PUT`), and update the Entity: +Update your `create_table` instance to add the `owners` field. Use the `Create` class, because this runs a `PUT`. Then update the Entity: ```python from metadata.generated.schema.type.entityReference import EntityReference -create_table.owner = EntityReference(id=user.id, type="user") +create_table.owners = [EntityReference(id=user.id, type="user")] updated_table_entity = metadata.create_or_update(create_table) -print(updated_table_entity.owner) -# EntityReference(id=Uuid(__root__=UUID('48793f0c-5308-45c1-9bf4-06a82c8d7bf9')), type='user', name='random-user', description=None, displayName=None, href=Href(__root__=AnyUrl('http://localhost:8585/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9', scheme='http', host='localhost', host_type='int_domain', port='8585', path='/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9'))) +print(updated_table_entity.owners.root[0].name) +# random-user ``` -If we did not save the `updated_table_entity` variable, we should need to query it to review the `owner` field. We can run the `get_by_name` using the proper FQN definition for `Table`s: +If you didn't save the `updated_table_entity` variable, query it to review the `owners` field. Run `get_by_name` with the FQN of the table: ```python my_table = metadata.get_by_name(entity=Table, fqn="test-service-table.test-db.test-schema.test") diff --git a/v2.0.x/sdk/python/api-reference.mdx b/v2.0.x/sdk/python/api-reference.mdx index f6c8131b8..8e08a3cb9 100644 --- a/v2.0.x/sdk/python/api-reference.mdx +++ b/v2.0.x/sdk/python/api-reference.mdx @@ -33,6 +33,7 @@ All entity types follow the same pattern: from metadata.sdk import Tables, Databases, DatabaseSchemas, DatabaseServices from metadata.sdk import Dashboards, Pipelines, MLModels, Tags, Classifications from metadata.sdk import Glossaries, GlossaryTerms, Users, Teams +from metadata.generated.schema.api.data.createTable import CreateTableRequest # Create entity = Tables.create(CreateTableRequest(...)) @@ -41,13 +42,18 @@ entity = Tables.create(CreateTableRequest(...)) entity = Tables.retrieve("uuid") entity = Tables.retrieve_by_name("service.db.schema.table", fields=["owners", "tags"]) -# List with auto-pagination -for table in Tables.list().auto_paging_iterable(): - print(table.name) +# List one page +page = Tables.list(limit=50) +for table in page.entities: + print(table.name.root) + +# List everything (follows the paging cursor for you) +for table in Tables.list_all(): + print(table.name.root) # Update entity.description = "Updated" -Tables.update(str(entity.id), entity) +Tables.update(entity) # Delete Tables.delete("uuid") @@ -68,7 +74,7 @@ Lineage.add_lineage( ) # Get lineage -lineage = Lineage.get_lineage("service.db.schema.table", upstream_depth=2, downstream_depth=2) +lineage = Lineage.get_lineage("service.db.schema.table", entity_type="table", upstream_depth=2, downstream_depth=2) ``` ### Error Handling @@ -78,9 +84,9 @@ from metadata.ingestion.ometa.client import APIError try: table = Tables.retrieve("table-id") -except APIError as e: - if e.status_code == 404: + if table is None: print("Not found") - elif e.status_code == 401: +except APIError as e: + if e.status_code == 401: print("Authentication failed") ``` diff --git a/v2.0.x/sdk/python/overview.mdx b/v2.0.x/sdk/python/overview.mdx index c193ace70..f65fdec21 100644 --- a/v2.0.x/sdk/python/overview.mdx +++ b/v2.0.x/sdk/python/overview.mdx @@ -2,6 +2,8 @@ title: Python SDK Overview description: 'Full-featured Python client library for OpenMetadata integration' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -15,7 +17,17 @@ Install the OpenMetadata Python SDK using pip: pip install openmetadata-ingestion ``` -## Quick Start + + +## Quick Start: SDK 2.0 + +Connect with `configure()`, then create, update, and delete a table: + + + +## Quick Start: Original Client + +Connect with `OpenMetadataConnection`, then read and update entities: ### Basic Connection @@ -31,7 +43,7 @@ from metadata.generated.schema.security.client.openMetadataJWTClientConfig impor # Configure connection server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -62,7 +74,7 @@ table = metadata.get_by_name( ) if table: - print(f"Table: {table.name}") + print(f"Table: {table.name.root}") print(f"Columns: {len(table.columns) if table.columns else 0}") ``` @@ -106,7 +118,7 @@ table = metadata.get_by_name( # List entities with pagination tables = metadata.list_entities( entity=Table, - fields=["owner", "tags"], + fields=["owners", "tags"], limit=50 ) ``` @@ -117,12 +129,12 @@ tables = metadata.list_entities( # Generator for large datasets all_tables = metadata.list_all_entities( entity=Table, - fields=["owner", "columns"], - params={"service": "your-service-name"} + fields=["owners", "columns"], + params={"databaseSchema": "your-service.your-database.your-schema"} ) for table in all_tables: - print(f"Processing table: {table.name}") + print(f"Processing table: {table.name.root}") ``` ### Entity References @@ -136,26 +148,26 @@ table_ref = metadata.get_entity_reference( # Use in other entity creation if table_ref: - print(f"Table reference: {table_ref.id}") + print(f"Table reference: {table_ref.id.root}") ``` ## Advanced Features -### Custom Configuration +### Validating a Custom Certificate Authority (CA) Certificate + +To trust a private CA, pass the path to its certificate in `sslConfig`: ```python -# Using custom authentication -from metadata.generated.schema.security.client.basicAuthenticationProvider import ( - BasicAuthenticationProvider, -) +from metadata.generated.schema.security.ssl.validateSSLClientConfig import ValidateSslClientConfig server_config = OpenMetadataConnection( hostPort="https://your-openmetadata-instance.com/api", - authProvider="basic", - securityConfig=BasicAuthenticationProvider( - username="your-username", - password="your-password" + authProvider="openmetadata", + securityConfig=OpenMetadataJWTClientConfig( + jwtToken="your-jwt-token" ), + verifySSL="validate", + sslConfig=ValidateSslClientConfig(caCertificate="/path/to/rootCert"), ) metadata = OpenMetadata(server_config) @@ -164,18 +176,10 @@ metadata = OpenMetadata(server_config) ### Error Handling ```python -from metadata.ingestion.ometa.ometa_api import ( - OpenMetadata, - InvalidEntityException, - EmptyPayloadException -) - -try: - table = metadata.get_by_name(entity=Table, fqn="non-existent-table") -except InvalidEntityException as e: - print(f"Invalid entity: {e}") -except EmptyPayloadException as e: - print(f"No data received: {e}") +# get_by_name returns None when the entity does not exist +table = metadata.get_by_name(entity=Table, fqn="non-existent-table") +if table is None: + print("Table not found") ``` ### Working with Versions @@ -200,11 +204,11 @@ all_tables = metadata.list_all_entities(entity=Table) matching_tables = [ table for table in all_tables - if "customer" in table.name.lower() + if "customer" in table.name.root.lower() ] for table in matching_tables: - print(f"Found customer table: {table.fullyQualifiedName}") + print(f"Found customer table: {table.fullyQualifiedName.root}") ``` ### Metadata Automation @@ -213,30 +217,28 @@ for table in matching_tables: # Bulk update table descriptions tables_to_update = metadata.list_all_entities( entity=Table, - params={"service": "production-db"} + params={"databaseSchema": "production-service.production-db.public"} ) for table in tables_to_update: if not table.description: # Update with a default description - table.description = f"Production table: {table.name}" + table.description = f"Production table: {table.name.root}" metadata.create_or_update(data=table) ``` ### Lineage Management ```python -from metadata.generated.schema.type.entityLineage import EntityLineage - -# Get table lineage +# Get table lineage (returns a dict) lineage = metadata.get_lineage_by_name( entity=Table, fqn="service.database.schema.table" ) if lineage: - print(f"Upstream entities: {len(lineage.upstreamEdges)}") - print(f"Downstream entities: {len(lineage.downstreamEdges)}") + print(f"Upstream edges: {len(lineage['upstreamEdges'])}") + print(f"Downstream edges: {len(lineage['downstreamEdges'])}") ``` ## API Reference diff --git a/v2.1.x-SNAPSHOT/api-reference.mdx b/v2.1.x-SNAPSHOT/api-reference.mdx index 621f0abc3..f11044876 100644 --- a/v2.1.x-SNAPSHOT/api-reference.mdx +++ b/v2.1.x-SNAPSHOT/api-reference.mdx @@ -86,10 +86,14 @@ metadata = OpenMetadata(server_config) # List tables tables = metadata.list_all_entities(entity=Table) for table in tables: - print(f"{table.fullyQualifiedName}: {table.description}") + print(f"{table.fullyQualifiedName.root}: {getattr(table.description, 'root', table.description)}") ``` ```java Java +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.models.ListParams; + // Configure connection OpenMetadataConfig config = OpenMetadataConfig.builder() .serverUrl("https://your-company.open-metadata.org/api") @@ -99,9 +103,8 @@ OpenMetadataConfig config = OpenMetadataConfig.builder() OpenMetadataClient client = new OpenMetadataClient(config); // List tables -TablesApi tablesApi = client.buildClient(TablesApi.class); -TableList tables = tablesApi.listTables(null, 10, null, null, null); -for (Table table : tables.getData()) { +var tables = client.tables().list(new ListParams().setLimit(10)); +for (var table : tables.getData()) { System.out.println(table.getFullyQualifiedName()); } ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/authentication.mdx b/v2.1.x-SNAPSHOT/api-reference/authentication.mdx index 9de94ea7b..03aa0f187 100644 --- a/v2.1.x-SNAPSHOT/api-reference/authentication.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/authentication.mdx @@ -81,21 +81,17 @@ tables = metadata.list_all_entities(entity=Table) ``` ```java Token Example -import org.openmetadata.client.gateway.OpenMetadata; -import org.openmetadata.schema.services.connections.metadata.OpenMetadataConnection; -import org.openmetadata.schema.security.client.OpenMetadataJWTClientConfig; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; // Configure with JWT token -OpenMetadataConnection config = new OpenMetadataConnection(); -config.setHostPort("https://your-company.open-metadata.org/api"); -config.setAuthProvider(AuthProvider.OPENMETADATA); - -OpenMetadataJWTClientConfig jwtConfig = new OpenMetadataJWTClientConfig(); -jwtConfig.setJwtToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."); -config.setSecurityConfig(jwtConfig); +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("https://your-company.open-metadata.org/api") + .accessToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...") + .build(); // Create authenticated client -OpenMetadata client = new OpenMetadata(config); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ```bash Token Example diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/create.mdx index f0abc3fef..7a97e534c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/create.mdx @@ -16,11 +16,11 @@ Create a new API collection within an API service. - Fully qualified name of the parent APIService (e.g., `sample_api_service`). + Fully qualified name of the parent APIService, for example `sample_api_service`. - Base URL for the API collection (e.g., `https://petstore3.swagger.io/#/pet`). + Base URL for the API collection, for example `https://petstore3.swagger.io/#/pet`. @@ -40,7 +40,7 @@ Create a new API collection within an API service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -49,8 +49,8 @@ Create a new API collection within an API service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -62,11 +62,11 @@ Create a new API collection within an API service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -94,19 +94,23 @@ request = CreateAPICollectionRequest( ) api_collection = APICollections.create(request) -print(f"Created: {api_collection.fullyQualifiedName}") +print(f"Created: {api_collection.fullyQualifiedName.root}") ``` ```java POST /v1/apiCollections -import static org.openmetadata.sdk.fluent.APICollections.*; - -// Create using builder pattern -var apiCollection = APICollections.builder() - .name("pet") - .service("sample_api_service") - .endpointURL("https://petstore3.swagger.io/#/pet") - .description("Pet-related API endpoints") - .create(); +import java.net.URI; +import org.openmetadata.schema.api.data.CreateAPICollection; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. + +CreateAPICollection request = new CreateAPICollection() + .withName("pet") + .withService("sample_api_service") + .withEndpointURL(URI.create("https://petstore3.swagger.io/#/pet")) + .withDescription("Pet-related API endpoints"); + +APICollection apiCollection = client.apiCollections().create(request); ``` ```bash POST /v1/apiCollections @@ -204,7 +208,7 @@ Returns the created API collection object with all specified properties and syst - Type of API service (e.g., Rest). + Type of API service, for example Rest. @@ -216,7 +220,7 @@ Returns the created API collection object with all specified properties and syst - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -238,11 +242,11 @@ Returns the created API collection object with all specified properties and syst - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/delete.mdx index b70156430..66238adf7 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/delete.mdx @@ -28,7 +28,7 @@ Delete an API collection by ID or fully qualified name. Supports soft delete (de Use `DELETE /v1/apiCollections/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the API collection (e.g., `sample_api_service.pet`). + Fully qualified name of the API collection, for example `sample_api_service.pet`. @@ -66,36 +66,40 @@ APICollections.delete( hard_delete=True ) -# Delete by name -APICollections.delete_by_name("sample_api_service.pet") +# Delete by name (look up the ID first) +entity = APICollections.retrieve_by_name("sample_api_service.pet") +APICollections.delete(entity.id) # Delete by name with options -APICollections.delete_by_name( - "sample_api_service.pet", - hard_delete=True -) +entity = APICollections.retrieve_by_name("sample_api_service.pet") +APICollections.delete(entity.id, hard_delete=True) # Restore a soft-deleted API collection APICollections.restore("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") ``` ```java DELETE /v1/apiCollections/{id} -import static org.openmetadata.sdk.fluent.APICollections.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -APICollections.delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b").execute(); +client.apiCollections().delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); // Hard delete -APICollections.delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") - .hardDelete() - .execute(); +client.apiCollections().delete("0f7ee81c-8163-4097-8adb-45c3d6c7b14b", Map.of("hardDelete", "true")); // Delete by name -APICollections.deleteByName("sample_api_service.pet") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/apiCollections/name/sample_api_service.pet", + null, + Void.class +); // Restore -APICollections.restore("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +client.apiCollections().restore("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); ``` ```bash DELETE /v1/apiCollections/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/list.mdx index 3407abaaf..07f3cc8e1 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/list.mdx @@ -47,48 +47,53 @@ configure( # List first page collections = APICollections.list(limit=50) -for ac in collections.data: - print(f"{ac.fullyQualifiedName}") +for ac in collections.entities: + print(f"{ac.fullyQualifiedName.root}") # List all with auto-pagination for ac in APICollections.list_all(): - print(f"{ac.fullyQualifiedName}") + print(f"{ac.fullyQualifiedName.root}") # Filter by service collections = APICollections.list( - service="sample_api_service", - fields=["owners", "tags", "domain"], + filters={"service": "sample_api_service"}, + fields=["owners", "tags", "domains"], limit=50 ) -for ac in collections.data: - print(f"{ac.fullyQualifiedName}") +for ac in collections.entities: + print(f"{ac.fullyQualifiedName.root}") if ac.owners: - print(f" Owners: {[o.name for o in ac.owners]}") + print(f" Owners: {[o.name for o in ac.owners.root]}") if ac.tags: - print(f" Tags: {[t.tagFQN for t in ac.tags]}") + print(f" Tags: {[t.tagFQN.root for t in ac.tags]}") ``` ```java GET /v1/apiCollections -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. // List first page -var result = APICollections.list() - .limit(50) - .execute(); +ListResponse firstPage = client.apiCollections().list( + new ListParams().setLimit(50) +); -for (var ac : result.getData()) { +for (APICollection ac : firstPage.getData()) { System.out.println(ac.getFullyQualifiedName()); } // Filter by service with fields -var result = APICollections.list() - .service("sample_api_service") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var ac : result.getData()) { +ListResponse filtered = client.apiCollections().list( + new ListParams() + .setService("sample_api_service") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (APICollection ac : filtered.getData()) { System.out.println(ac.getFullyQualifiedName()); } ``` @@ -180,7 +185,7 @@ Returns a paginated list of API collection objects. By default, only basic field - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/retrieve.mdx index f0e976e4f..6315ccb3d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/retrieve.mdx @@ -16,7 +16,7 @@ Get a single API collection by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single API collection by its unique ID or fully qualified name. Use `GET /v1/apiCollections/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the API collection (e.g., `sample_api_service.pet`). + Fully qualified name of the API collection, for example `sample_api_service.pet`. @@ -51,7 +51,7 @@ configure( # Get by ID ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") -print(f"{ac.fullyQualifiedName}: {ac.description}") +print(f"{ac.fullyQualifiedName.root}: {ac.name.root}") # Get by ID with fields ac = APICollections.retrieve( @@ -65,31 +65,33 @@ ac = APICollections.retrieve_by_name("sample_api_service.pet") # Get by name with fields ac = APICollections.retrieve_by_name( "sample_api_service.pet", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/apiCollections/{id} -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. // Get by ID -var ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +APICollection ac = client.apiCollections().get("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); // Get by ID with fields -var ac = APICollections.retrieve( +APICollection acWithFields = client.apiCollections().get( "0f7ee81c-8163-4097-8adb-45c3d6c7b14b", "owners,tags" ); // Get by fully qualified name -var ac = APICollections.retrieveByName( +APICollection acByName = client.apiCollections().getByName( "sample_api_service.pet" ); // Get by name with fields -var ac = APICollections.retrieveByName( +APICollection acByNameWithFields = client.apiCollections().getByName( "sample_api_service.pet", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -194,7 +196,7 @@ Returns an API collection object with all requested fields populated. - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/update.mdx index 38735efd1..65160f2a0 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/update.mdx @@ -20,7 +20,7 @@ Update an API collection's properties using JSON Merge Patch. You can update by Use `PATCH /v1/apiCollections/name/{fqn}` to update by fully qualified name. - Fully qualified name of the API collection (e.g., `sample_api_service.pet`). + Fully qualified name of the API collection, for example `sample_api_service.pet`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -62,17 +62,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -94,16 +94,18 @@ ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") ac.description = "Updated: Pet-related API endpoints for the Petstore service" updated = APICollections.update(ac) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/apiCollections/{id} -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.schema.entity.data.APICollection; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var ac = APICollections.retrieve("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +APICollection ac = client.apiCollections().get("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); ac.setDescription("Updated: Pet-related API endpoints for the Petstore service"); -var updated = APICollections.update(ac); +APICollection updated = client.apiCollections().update("0f7ee81c-8163-4097-8adb-45c3d6c7b14b", ac); ``` ```bash PATCH /v1/apiCollections/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/versions.mdx index 9fc8af7e1..7f880d3ce 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-collections/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/apiCollections/{id}/versions/{version}` to retrieve a specific vers - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/apiCollections/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import APICollections @@ -40,28 +42,30 @@ configure( # List all versions versions = APICollections.get_versions("0f7ee81c-8163-4097-8adb-45c3d6c7b14b") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version ac_v1 = APICollections.get_specific_version( "0f7ee81c-8163-4097-8adb-45c3d6c7b14b", "0.1" ) -print(f"Original description: {ac_v1.description}") +print(f"Original description: {ac_v1.description.root if ac_v1.description else None}") ``` ```java GET /v1/apiCollections/{id}/versions -import static org.openmetadata.sdk.fluent.APICollections.*; +import org.openmetadata.schema.entity.data.APICollection; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = APICollections.getVersions("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); +EntityHistory history = client.apiCollections().getVersionList("0f7ee81c-8163-4097-8adb-45c3d6c7b14b"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = APICollections.getSpecificVersion( +APICollection v1 = client.apiCollections().getVersion( "0f7ee81c-8163-4097-8adb-45c3d6c7b14b", 0.1 ); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/create.mdx index cc5043d76..372802543 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/create.mdx @@ -16,11 +16,11 @@ Create a new API endpoint within an API collection. - Fully qualified name of the parent APICollection (e.g., `sample_api_service.pet`). + Fully qualified name of the parent APICollection, for example `sample_api_service.pet`. - URL for the API endpoint (e.g., `https://petstore3.swagger.io/#/pet/addPet`). + URL for the API endpoint, for example `https://petstore3.swagger.io/#/pet/addPet`. @@ -32,7 +32,7 @@ Create a new API endpoint within an API collection. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -44,7 +44,7 @@ Create a new API endpoint within an API collection. - Data type of the field (e.g., `INT`, `STRING`, `OBJECT`). + Data type of the field, for example `INT`, `STRING`, `OBJECT`. @@ -60,7 +60,7 @@ Create a new API endpoint within an API collection. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -100,7 +100,7 @@ Create a new API endpoint within an API collection. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -109,8 +109,8 @@ Create a new API endpoint within an API collection. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -122,11 +122,11 @@ Create a new API endpoint within an API collection. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -162,21 +162,26 @@ request = CreateAPIEndpointRequest( ) endpoint = APIEndpoints.create(request) -print(f"Created: {endpoint.fullyQualifiedName}") +print(f"Created: {endpoint.fullyQualifiedName.root}") ``` ```java POST /v1/apiEndpoints -import static org.openmetadata.sdk.fluent.APIEndpoints.*; - -// Create using builder pattern -var endpoint = APIEndpoints.builder() - .name("addPet") - .displayName("Add Pet") - .apiCollection("sample_api_service.pet") - .description("Add a new pet to the store") - .endpointURL("https://petstore3.swagger.io/#/pet/addPet") - .requestMethod("POST") - .create(); +import java.net.URI; +import org.openmetadata.schema.api.data.CreateAPIEndpoint; +import org.openmetadata.schema.entity.data.APIEndpoint; +import org.openmetadata.schema.type.APIRequestMethod; + +// client is an initialized OpenMetadataClient. + +CreateAPIEndpoint request = new CreateAPIEndpoint() + .withName("addPet") + .withDisplayName("Add Pet") + .withApiCollection("sample_api_service.pet") + .withDescription("Add a new pet to the store") + .withEndpointURL(URI.create("https://petstore3.swagger.io/#/pet/addPet")) + .withRequestMethod(APIRequestMethod.POST); + +APIEndpoint endpoint = client.apiEndpoints().create(request); ``` ```bash POST /v1/apiEndpoints @@ -276,7 +281,7 @@ Returns the created API endpoint object with all specified properties and system - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -290,7 +295,7 @@ Returns the created API endpoint object with all specified properties and system - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -318,7 +323,7 @@ Returns the created API endpoint object with all specified properties and system - Type of API service (e.g., Rest). + Type of API service, for example Rest. @@ -330,7 +335,7 @@ Returns the created API endpoint object with all specified properties and system - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -352,11 +357,11 @@ Returns the created API endpoint object with all specified properties and system - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/delete.mdx index d5370aa3e..2dbcc6ec3 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/delete.mdx @@ -28,7 +28,7 @@ Delete an API endpoint by ID or fully qualified name. Supports soft delete (defa Use `DELETE /v1/apiEndpoints/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the API endpoint (e.g., `sample_api_service.pet.addPet`). + Fully qualified name of the API endpoint, for example `sample_api_service.pet.addPet`. @@ -66,36 +66,40 @@ APIEndpoints.delete( hard_delete=True ) -# Delete by name -APIEndpoints.delete_by_name("sample_api_service.pet.addPet") +# Delete by name (look up the ID first) +entity = APIEndpoints.retrieve_by_name("sample_api_service.pet.addPet") +APIEndpoints.delete(entity.id) # Delete by name with options -APIEndpoints.delete_by_name( - "sample_api_service.pet.addPet", - hard_delete=True -) +entity = APIEndpoints.retrieve_by_name("sample_api_service.pet.addPet") +APIEndpoints.delete(entity.id, hard_delete=True) # Restore a soft-deleted API endpoint APIEndpoints.restore("1f61427a-4a64-4070-9ac8-1d29302dac7c") ``` ```java DELETE /v1/apiEndpoints/{id} -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -APIEndpoints.delete("1f61427a-4a64-4070-9ac8-1d29302dac7c").execute(); +client.apiEndpoints().delete("1f61427a-4a64-4070-9ac8-1d29302dac7c"); // Hard delete -APIEndpoints.delete("1f61427a-4a64-4070-9ac8-1d29302dac7c") - .hardDelete() - .execute(); +client.apiEndpoints().delete("1f61427a-4a64-4070-9ac8-1d29302dac7c", Map.of("hardDelete", "true")); // Delete by name -APIEndpoints.deleteByName("sample_api_service.pet.addPet") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/apiEndpoints/name/sample_api_service.pet.addPet", + null, + Void.class +); // Restore -APIEndpoints.restore("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +client.apiEndpoints().restore("1f61427a-4a64-4070-9ac8-1d29302dac7c"); ``` ```bash DELETE /v1/apiEndpoints/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/list.mdx index 47ea4d849..86b88b86b 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/list.mdx @@ -51,48 +51,53 @@ configure( # List first page endpoints = APIEndpoints.list(limit=50) -for ep in endpoints.data: - print(f"{ep.fullyQualifiedName}") +for ep in endpoints.entities: + print(f"{ep.fullyQualifiedName.root}") # List all with auto-pagination for ep in APIEndpoints.list_all(): - print(f"{ep.fullyQualifiedName}") + print(f"{ep.fullyQualifiedName.root}") # Filter by API collection endpoints = APIEndpoints.list( - apiCollection="sample_api_service.pet", - fields=["owners", "tags", "domain"], + filters={"apiCollection": "sample_api_service.pet"}, + fields=["owners", "tags", "domains"], limit=50 ) -for ep in endpoints.data: - print(f"{ep.fullyQualifiedName} [{ep.requestMethod}]") +for ep in endpoints.entities: + print(f"{ep.fullyQualifiedName.root} [{ep.requestMethod.value}]") if ep.owners: - print(f" Owners: {[o.name for o in ep.owners]}") + print(f" Owners: {[o.name for o in ep.owners.root]}") if ep.tags: - print(f" Tags: {[t.tagFQN for t in ep.tags]}") + print(f" Tags: {[t.tagFQN.root for t in ep.tags]}") ``` ```java GET /v1/apiEndpoints -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.APIEndpoint; + +// client is an initialized OpenMetadataClient. // List first page -var result = APIEndpoints.list() - .limit(50) - .execute(); +ListResponse firstPage = client.apiEndpoints().list( + new ListParams().setLimit(50) +); -for (var ep : result.getData()) { +for (APIEndpoint ep : firstPage.getData()) { System.out.println(ep.getFullyQualifiedName()); } // Filter by API collection with fields -var result = APIEndpoints.list() - .apiCollection("sample_api_service.pet") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var ep : result.getData()) { +ListResponse filtered = client.apiEndpoints().list( + new ListParams() + .addFilter("apiCollection", "sample_api_service.pet") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (APIEndpoint ep : filtered.getData()) { System.out.println(ep.getFullyQualifiedName()); } ``` @@ -196,7 +201,7 @@ Returns a paginated list of API endpoint objects. By default, only basic fields - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/retrieve.mdx index d559c9ca2..c01ae707e 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/retrieve.mdx @@ -16,7 +16,7 @@ Get a single API endpoint by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single API endpoint by its unique ID or fully qualified name. Use `GET /v1/apiEndpoints/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the API endpoint (e.g., `sample_api_service.pet.addPet`). + Fully qualified name of the API endpoint, for example `sample_api_service.pet.addPet`. @@ -51,7 +51,7 @@ configure( # Get by ID ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c") -print(f"{ep.fullyQualifiedName}: {ep.description}") +print(f"{ep.fullyQualifiedName.root}: {ep.name.root}") # Get by ID with fields ep = APIEndpoints.retrieve( @@ -65,31 +65,33 @@ ep = APIEndpoints.retrieve_by_name("sample_api_service.pet.addPet") # Get by name with fields ep = APIEndpoints.retrieve_by_name( "sample_api_service.pet.addPet", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/apiEndpoints/{id} -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.schema.entity.data.APIEndpoint; + +// client is an initialized OpenMetadataClient. // Get by ID -var ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +APIEndpoint ep = client.apiEndpoints().get("1f61427a-4a64-4070-9ac8-1d29302dac7c"); // Get by ID with fields -var ep = APIEndpoints.retrieve( +APIEndpoint epWithFields = client.apiEndpoints().get( "1f61427a-4a64-4070-9ac8-1d29302dac7c", "owners,tags" ); // Get by fully qualified name -var ep = APIEndpoints.retrieveByName( +APIEndpoint epByName = client.apiEndpoints().getByName( "sample_api_service.pet.addPet" ); // Get by name with fields -var ep = APIEndpoints.retrieveByName( +APIEndpoint epByNameWithFields = client.apiEndpoints().getByName( "sample_api_service.pet.addPet", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -188,7 +190,7 @@ Returns an API endpoint object with all requested fields populated. - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -202,7 +204,7 @@ Returns an API endpoint object with all requested fields populated. - Type of schema (e.g., JSON). + Type of schema, for example JSON. @@ -230,7 +232,7 @@ Returns an API endpoint object with all requested fields populated. - Type of API service (e.g., Rest). + Type of API service, for example Rest. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/update.mdx index 595980a7c..456768692 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/update.mdx @@ -20,7 +20,7 @@ Update an API endpoint's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/apiEndpoints/name/{fqn}` to update by fully qualified name. - Fully qualified name of the API endpoint (e.g., `sample_api_service.pet.addPet`). + Fully qualified name of the API endpoint, for example `sample_api_service.pet.addPet`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -62,7 +62,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of schema (e.g., `JSON`). + Type of schema, for example `JSON`. @@ -80,7 +80,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -94,17 +94,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -126,16 +126,18 @@ ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c") ep.description = "Updated: Add a new pet to the store inventory" updated = APIEndpoints.update(ep) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/apiEndpoints/{id} -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.schema.entity.data.APIEndpoint; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var ep = APIEndpoints.retrieve("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +APIEndpoint ep = client.apiEndpoints().get("1f61427a-4a64-4070-9ac8-1d29302dac7c"); ep.setDescription("Updated: Add a new pet to the store inventory"); -var updated = APIEndpoints.update(ep); +APIEndpoint updated = client.apiEndpoints().update("1f61427a-4a64-4070-9ac8-1d29302dac7c", ep); ``` ```bash PATCH /v1/apiEndpoints/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/versions.mdx index 81d53a748..888cda388 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/api-endpoints/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/apiEndpoints/{id}/versions/{version}` to retrieve a specific versio - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/apiEndpoints/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import APIEndpoints @@ -40,28 +42,30 @@ configure( # List all versions versions = APIEndpoints.get_versions("1f61427a-4a64-4070-9ac8-1d29302dac7c") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version ep_v1 = APIEndpoints.get_specific_version( "1f61427a-4a64-4070-9ac8-1d29302dac7c", "0.1" ) -print(f"Original description: {ep_v1.description}") +print(f"Original description: {ep_v1.description.root if ep_v1.description else None}") ``` ```java GET /v1/apiEndpoints/{id}/versions -import static org.openmetadata.sdk.fluent.APIEndpoints.*; +import org.openmetadata.schema.entity.data.APIEndpoint; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = APIEndpoints.getVersions("1f61427a-4a64-4070-9ac8-1d29302dac7c"); +EntityHistory history = client.apiEndpoints().getVersionList("1f61427a-4a64-4070-9ac8-1d29302dac7c"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = APIEndpoints.getSpecificVersion( +APIEndpoint v1 = client.apiEndpoints().getVersion( "1f61427a-4a64-4070-9ac8-1d29302dac7c", 0.1 ); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/create.mdx index 9846abb83..a113dcd46 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/create.mdx @@ -16,7 +16,7 @@ Create a new chart within a dashboard service. - Fully qualified name of the parent DashboardService (e.g., `sample_superset`). + Fully qualified name of the parent DashboardService, for example `sample_superset`. @@ -44,7 +44,7 @@ Create a new chart within a dashboard service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -53,8 +53,8 @@ Create a new chart within a dashboard service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -66,11 +66,11 @@ Create a new chart within a dashboard service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -100,21 +100,25 @@ request = CreateChartRequest( ) chart = Charts.create(request) -print(f"Created: {chart.fullyQualifiedName}") +print(f"Created: {chart.fullyQualifiedName.root}") ``` ```java POST /v1/charts -import static org.openmetadata.sdk.fluent.Charts.*; - -// Create using builder pattern -var chart = Charts.builder() - .name("114") - .displayName("# of Games That Hit 100k in Sales By Release Year") - .service("sample_superset") - .description("Bar chart showing games that hit 100k in sales by release year") - .chartType("Other") - .sourceUrl("http://localhost:808/explore/?slice_id=114") - .create(); +import org.openmetadata.schema.api.data.CreateChart; +import org.openmetadata.schema.entity.data.Chart; +import org.openmetadata.schema.type.ChartType; + +// client is an initialized OpenMetadataClient. + +CreateChart request = new CreateChart() + .withName("114") + .withDisplayName("# of Games That Hit 100k in Sales By Release Year") + .withService("sample_superset") + .withDescription("Bar chart showing games that hit 100k in sales by release year") + .withChartType(ChartType.Other) + .withSourceUrl("http://localhost:808/explore/?slice_id=114"); + +Chart chart = client.charts().create(request); ``` ```bash POST /v1/charts @@ -196,7 +200,7 @@ Returns the created chart object with all specified properties and system-genera - Type of chart visualization (e.g., Line, Bar, Area, Pie, Scatter, Table, Histogram, Other). + Type of chart visualization, for example Line, Bar, Area, Pie, Scatter, Table, Histogram, Other. @@ -226,7 +230,7 @@ Returns the created chart object with all specified properties and system-genera - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. @@ -238,7 +242,7 @@ Returns the created chart object with all specified properties and system-genera - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -260,11 +264,11 @@ Returns the created chart object with all specified properties and system-genera - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/delete.mdx index 22cd4cc29..ad6b2972c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/delete.mdx @@ -28,7 +28,7 @@ Delete a chart by ID or fully qualified name. Supports soft delete (default), ha Use `DELETE /v1/charts/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the chart (e.g., `sample_superset.114`). + Fully qualified name of the chart, for example `sample_superset.114`. @@ -66,36 +66,40 @@ Charts.delete( hard_delete=True ) -# Delete by name -Charts.delete_by_name("sample_superset.114") +# Delete by name (look up the ID first) +entity = Charts.retrieve_by_name("sample_superset.114") +Charts.delete(entity.id) # Delete by name with options -Charts.delete_by_name( - "sample_superset.114", - hard_delete=True -) +entity = Charts.retrieve_by_name("sample_superset.114") +Charts.delete(entity.id, hard_delete=True) # Restore a soft-deleted chart Charts.restore("2dde4b53-a577-424b-bbaa-18ac32eca8a9") ``` ```java DELETE /v1/charts/{id} -import static org.openmetadata.sdk.fluent.Charts.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -Charts.delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9").execute(); +client.charts().delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); // Hard delete -Charts.delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9") - .hardDelete() - .execute(); +client.charts().delete("2dde4b53-a577-424b-bbaa-18ac32eca8a9", Map.of("hardDelete", "true")); // Delete by name -Charts.deleteByName("sample_superset.114") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/charts/name/sample_superset.114", + null, + Void.class +); // Restore -Charts.restore("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +client.charts().restore("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); ``` ```bash DELETE /v1/charts/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/list.mdx index 87d2e7a08..1a941a61b 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/list.mdx @@ -47,49 +47,54 @@ configure( # List first page charts = Charts.list(limit=50) -for c in charts.data: - print(f"{c.fullyQualifiedName}") +for c in charts.entities: + print(f"{c.fullyQualifiedName.root}") # List all with auto-pagination for c in Charts.list_all(): - print(f"{c.fullyQualifiedName}") + print(f"{c.fullyQualifiedName.root}") # Filter by service charts = Charts.list( - service="sample_superset", + filters={"service": "sample_superset"}, fields=["owners", "tags", "domains"], limit=50 ) -for c in charts.data: - print(f"{c.fullyQualifiedName} ({c.chartType})") +for c in charts.entities: + print(f"{c.fullyQualifiedName.root} ({c.chartType.value})") if c.owners: - print(f" Owners: {[o.name for o in c.owners]}") + print(f" Owners: {[o.name for o in c.owners.root]}") if c.tags: - print(f" Tags: {[t.tagFQN for t in c.tags]}") + print(f" Tags: {[t.tagFQN.root for t in c.tags]}") ``` ```java GET /v1/charts -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.Chart; + +// client is an initialized OpenMetadataClient. // List first page -var result = Charts.list() - .limit(50) - .execute(); +ListResponse firstPage = client.charts().list( + new ListParams().setLimit(50) +); -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +for (Chart chart : firstPage.getData()) { + System.out.println(chart.getFullyQualifiedName()); } // Filter by service with fields -var result = Charts.list() - .service("sample_superset") - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +ListResponse filtered = client.charts().list( + new ListParams() + .setService("sample_superset") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (Chart chart : filtered.getData()) { + System.out.println(chart.getFullyQualifiedName()); } ``` @@ -187,7 +192,7 @@ Returns a paginated list of chart objects. By default, only basic fields are inc - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/retrieve.mdx index ddc8cb3c7..3fd56d77c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/retrieve.mdx @@ -16,7 +16,7 @@ Get a single chart by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single chart by its unique ID or fully qualified name. Use `GET /v1/charts/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the chart (e.g., `sample_superset.114`). + Fully qualified name of the chart, for example `sample_superset.114`. @@ -51,7 +51,7 @@ configure( # Get by ID chart = Charts.retrieve("2dde4b53-a577-424b-bbaa-18ac32eca8a9") -print(f"{chart.fullyQualifiedName}: {chart.displayName}") +print(f"{chart.fullyQualifiedName.root}: {chart.displayName}") # Get by ID with fields chart = Charts.retrieve( @@ -70,22 +70,26 @@ chart = Charts.retrieve_by_name( ``` ```java GET /v1/charts/{id} -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.schema.entity.data.Chart; + +// client is an initialized OpenMetadataClient. // Get by ID -var chart = Charts.retrieve("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +Chart chart = client.charts().get("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); // Get by ID with fields -var chart = Charts.retrieve( +Chart chartWithFields = client.charts().get( "2dde4b53-a577-424b-bbaa-18ac32eca8a9", "owners,tags" ); // Get by fully qualified name -var chart = Charts.retrieveByName("sample_superset.114"); +Chart chartByName = client.charts().getByName( + "sample_superset.114" +); // Get by name with fields -var chart = Charts.retrieveByName( +Chart chartByNameWithFields = client.charts().getByName( "sample_superset.114", "owners,tags,domains" ); @@ -203,7 +207,7 @@ Returns a chart object with all requested fields populated. - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/update.mdx index 88b1254f1..781389c09 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/update.mdx @@ -20,7 +20,7 @@ Update a chart's properties using JSON Merge Patch. You can update by ID or by f Use `PATCH /v1/charts/name/{fqn}` to update by fully qualified name. - Fully qualified name of the chart (e.g., `sample_superset.114`). + Fully qualified name of the chart, for example `sample_superset.114`. ## Body Parameters @@ -52,7 +52,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,17 +66,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -99,16 +99,18 @@ chart.description = "Updated: Bar chart showing top-selling games by release yea chart.chartType = "Bar" updated = Charts.update(chart) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/charts/{id} -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.schema.entity.data.Chart; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var chart = Charts.retrieve("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +Chart chart = client.charts().get("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); chart.setDescription("Updated: Bar chart showing top-selling games by release year"); -var updated = Charts.update(chart); +Chart updated = client.charts().update("2dde4b53-a577-424b-bbaa-18ac32eca8a9", chart); ``` ```bash PATCH /v1/charts/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/versions.mdx index 879d3da3f..3fbe2d8f1 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/charts/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/charts/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/charts/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Charts @@ -40,28 +42,30 @@ configure( # List all versions versions = Charts.get_versions("2dde4b53-a577-424b-bbaa-18ac32eca8a9") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version chart_v1 = Charts.get_specific_version( "2dde4b53-a577-424b-bbaa-18ac32eca8a9", "0.1" ) -print(f"Original description: {chart_v1.description}") +print(f"Original description: {chart_v1.description.root if chart_v1.description else None}") ``` ```java GET /v1/charts/{id}/versions -import static org.openmetadata.sdk.fluent.Charts.*; +import org.openmetadata.schema.entity.data.Chart; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Charts.getVersions("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); +EntityHistory history = client.charts().getVersionList("2dde4b53-a577-424b-bbaa-18ac32eca8a9"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = Charts.getSpecificVersion( +Chart v1 = client.charts().getVersion( "2dde4b53-a577-424b-bbaa-18ac32eca8a9", 0.1 ); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/create.mdx index 1bd5340b9..67f0fb641 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/create.mdx @@ -16,7 +16,7 @@ Create a new container within a storage service. - Fully qualified name of the parent StorageService (e.g., `s3_datalake`). + Fully qualified name of the parent StorageService, for example `s3_datalake`. @@ -42,7 +42,7 @@ Create a new container within a storage service. - Path prefix for objects in the container (e.g., `/raw/events/`). + Path prefix for objects in the container, for example `/raw/events/`. @@ -54,7 +54,7 @@ Create a new container within a storage service. - List of file formats stored in the container (e.g., `csv`, `tsv`, `parquet`, `avro`, `json`, `jsonl`, `jsonGz`, `jsonZip`). + List of file formats stored in the container, for example `csv`, `tsv`, `parquet`, `avro`, `json`, `jsonl`, `jsonGz`, `jsonZip`. @@ -74,7 +74,7 @@ Create a new container within a storage service. - Data type (e.g., `STRING`, `INT`, `DOUBLE`, `TIMESTAMP`). + Data type, for example `STRING`, `INT`, `DOUBLE`, `TIMESTAMP`. @@ -86,7 +86,7 @@ Create a new container within a storage service. - Full path of the container (e.g., `s3://analytics-bucket/raw/events`). + Full path of the container, for example `s3://analytics-bucket/raw/events`. @@ -98,7 +98,7 @@ Create a new container within a storage service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -107,8 +107,8 @@ Create a new container within a storage service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -120,11 +120,11 @@ Create a new container within a storage service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -165,23 +165,28 @@ request = CreateContainerRequest( ) container = Containers.create(request) -print(f"Created: {container.fullyQualifiedName}") +print(f"Created: {container.fullyQualifiedName.root}") ``` ```java POST /v1/containers -import static org.openmetadata.sdk.fluent.Containers.*; - -// Create using builder pattern -var container = Containers.builder() - .name("analytics-bucket") - .displayName("Analytics Bucket") - .service("s3_datalake") - .description("Primary analytics data lake bucket") - .prefix("/analytics/") - .numberOfObjects(150000) - .size(5368709120L) - .fileFormats("parquet", "json") - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateContainer; +import org.openmetadata.schema.entity.data.Container; +import org.openmetadata.schema.type.ContainerFileFormat; + +// client is an initialized OpenMetadataClient. + +CreateContainer request = new CreateContainer() + .withName("analytics-bucket") + .withDisplayName("Analytics Bucket") + .withService("s3_datalake") + .withDescription("Primary analytics data lake bucket") + .withPrefix("/analytics/") + .withNumberOfObjects(150000.0) + .withSize(5368709120.0) + .withFileFormats(List.of(ContainerFileFormat.Parquet, ContainerFileFormat.Json)); + +Container container = client.containers().create(request); ``` ```bash POST /v1/containers @@ -307,7 +312,7 @@ Returns the created container object with all specified properties and system-ge - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -353,7 +358,7 @@ Returns the created container object with all specified properties and system-ge - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -375,11 +380,11 @@ Returns the created container object with all specified properties and system-ge - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/delete.mdx index 6e7ec2f34..dc3560e11 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/delete.mdx @@ -28,7 +28,7 @@ Delete a container by ID or fully qualified name. Supports soft delete (default) Use `DELETE /v1/containers/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the container (e.g., `s3_datalake.analytics-bucket`). + Fully qualified name of the container, for example `s3_datalake.analytics-bucket`. @@ -66,36 +66,40 @@ Containers.delete( hard_delete=True ) -# Delete by name -Containers.delete_by_name("s3_datalake.analytics-bucket") +# Delete by name (look up the ID first) +entity = Containers.retrieve_by_name("s3_datalake.analytics-bucket") +Containers.delete(entity.id) # Delete by name with options -Containers.delete_by_name( - "s3_datalake.analytics-bucket", - hard_delete=True, - recursive=True -) +entity = Containers.retrieve_by_name("s3_datalake.analytics-bucket") +Containers.delete(entity.id, hard_delete=True, recursive=True) # Restore a soft-deleted container Containers.restore("14744329-85c2-499e-b1fa-249fb8162341") ``` ```java DELETE /v1/containers/{id} -import static org.openmetadata.sdk.fluent.Containers.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -Containers.delete("14744329-85c2-499e-b1fa-249fb8162341").execute(); +client.containers().delete("14744329-85c2-499e-b1fa-249fb8162341"); // Hard delete -Containers.delete("14744329-85c2-499e-b1fa-249fb8162341") - .hardDelete() - .execute(); +client.containers().delete("14744329-85c2-499e-b1fa-249fb8162341", Map.of("hardDelete", "true")); // Delete by name -Containers.deleteByName("s3_datalake.analytics-bucket").execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/containers/name/s3_datalake.analytics-bucket", + null, + Void.class +); // Restore -Containers.restore("14744329-85c2-499e-b1fa-249fb8162341"); +client.containers().restore("14744329-85c2-499e-b1fa-249fb8162341"); ``` ```bash DELETE /v1/containers/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/list.mdx index 49abe6bbe..a50a0ef38 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/list.mdx @@ -28,7 +28,7 @@ List all containers with optional filtering and pagination. - Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `children`, `sourceHash`. See [Supported Fields](#supported-fields) below. + Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `sourceHash`. See [Supported Fields](#supported-fields) below. @@ -47,49 +47,54 @@ configure( # List first page containers = Containers.list(limit=50) -for c in containers.data: - print(f"{c.fullyQualifiedName}") +for c in containers.entities: + print(f"{c.fullyQualifiedName.root}") # List all with auto-pagination for c in Containers.list_all(): - print(f"{c.fullyQualifiedName}") + print(f"{c.fullyQualifiedName.root}") # Filter by storage service containers = Containers.list( - service="s3_datalake", + filters={"service": "s3_datalake"}, fields=["owners", "tags", "dataModel"], limit=50 ) -for c in containers.data: - print(f"{c.fullyQualifiedName}") +for c in containers.entities: + print(f"{c.fullyQualifiedName.root}") if c.owners: - print(f" Owners: {[o.name for o in c.owners]}") + print(f" Owners: {[o.name for o in c.owners.root]}") if c.tags: - print(f" Tags: {[t.tagFQN for t in c.tags]}") + print(f" Tags: {[t.tagFQN.root for t in c.tags]}") ``` ```java GET /v1/containers -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.Container; + +// client is an initialized OpenMetadataClient. // List first page -var result = Containers.list() - .limit(50) - .execute(); +ListResponse firstPage = client.containers().list( + new ListParams().setLimit(50) +); -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +for (Container container : firstPage.getData()) { + System.out.println(container.getFullyQualifiedName()); } -// Filter by storage service with fields -var result = Containers.list() - .service("s3_datalake") - .fields("owners", "tags", "dataModel") - .limit(50) - .execute(); +// Filter by service with fields +ListResponse filtered = client.containers().list( + new ListParams() + .setService("s3_datalake") + .setFields("owners,tags,dataModel") + .setLimit(50) +); -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +for (Container container : filtered.getData()) { + System.out.println(container.getFullyQualifiedName()); } ``` @@ -103,7 +108,7 @@ curl "{base_url}/api/v1/containers?service=s3_datalake&limit=50" \ -H "Authorization: Bearer {access_token}" # With fields -curl "{base_url}/api/v1/containers?service=s3_datalake&fields=owners,tags,dataModel,children&limit=50" \ +curl "{base_url}/api/v1/containers?service=s3_datalake&fields=owners,tags,dataModel&limit=50" \ -H "Authorization: Bearer {access_token}" ``` @@ -186,7 +191,7 @@ Returns a paginated list of container objects. By default, only basic fields are - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -229,10 +234,6 @@ Returns a paginated list of container objects. By default, only basic fields are Data model describing the schema of files. Only included when `fields` contains `dataModel`. - - Nested child containers. Only included when `fields` contains `children`. - - Custom properties. Only included when `fields` contains `extension`. @@ -272,7 +273,6 @@ The following fields can be requested via the `fields` query parameter: | `extension` | Custom property values | | `domains` | Domain assignments for governance | | `dataModel` | Data model with column definitions | -| `children` | Nested child containers | | `sourceHash` | Hash for change detection | --- diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/retrieve.mdx index cdd8cebd7..ba7e84161 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/retrieve.mdx @@ -16,7 +16,7 @@ Get a single container by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,dataModel,children,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,dataModel,sourceHash`. @@ -28,11 +28,11 @@ Get a single container by its unique ID or fully qualified name. Use `GET /v1/containers/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the container (e.g., `s3_datalake.analytics-bucket`). + Fully qualified name of the container, for example `s3_datalake.analytics-bucket`. - Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `children`, `sourceHash`. + Comma-separated list of fields to include: `owners`, `tags`, `followers`, `votes`, `extension`, `domains`, `dataModel`, `sourceHash`. @@ -51,12 +51,12 @@ configure( # Get by ID container = Containers.retrieve("14744329-85c2-499e-b1fa-249fb8162341") -print(f"{container.fullyQualifiedName}: {container.description}") +print(f"{container.fullyQualifiedName.root}: {container.name.root}") # Get by ID with fields container = Containers.retrieve( "14744329-85c2-499e-b1fa-249fb8162341", - fields=["owners", "tags", "dataModel", "children"] + fields=["owners", "tags", "dataModel"] ) # Get by fully qualified name @@ -65,29 +65,33 @@ container = Containers.retrieve_by_name("s3_datalake.analytics-bucket") # Get by name with fields container = Containers.retrieve_by_name( "s3_datalake.analytics-bucket", - fields=["owners", "tags", "dataModel", "children"] + fields=["owners", "tags", "dataModel"] ) ``` ```java GET /v1/containers/{id} -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.schema.entity.data.Container; + +// client is an initialized OpenMetadataClient. // Get by ID -var container = Containers.retrieve("14744329-85c2-499e-b1fa-249fb8162341"); +Container container = client.containers().get("14744329-85c2-499e-b1fa-249fb8162341"); // Get by ID with fields -var container = Containers.retrieve( +Container containerWithFields = client.containers().get( "14744329-85c2-499e-b1fa-249fb8162341", - "owners,tags,dataModel,children" + "owners,tags,dataModel" ); // Get by fully qualified name -var container = Containers.retrieveByName("s3_datalake.analytics-bucket"); +Container containerByName = client.containers().getByName( + "s3_datalake.analytics-bucket" +); // Get by name with fields -var container = Containers.retrieveByName( +Container containerByNameWithFields = client.containers().getByName( "s3_datalake.analytics-bucket", - "owners,tags,dataModel,children" + "owners,tags,dataModel" ); ``` @@ -97,7 +101,7 @@ curl "{base_url}/api/v1/containers/14744329-85c2-499e-b1fa-249fb8162341" \ -H "Authorization: Bearer {access_token}" # Get by ID with fields -curl "{base_url}/api/v1/containers/14744329-85c2-499e-b1fa-249fb8162341?fields=owners,tags,dataModel,children" \ +curl "{base_url}/api/v1/containers/14744329-85c2-499e-b1fa-249fb8162341?fields=owners,tags,dataModel" \ -H "Authorization: Bearer {access_token}" # Get by fully qualified name @@ -105,7 +109,7 @@ curl "{base_url}/api/v1/containers/name/s3_datalake.analytics-bucket" \ -H "Authorization: Bearer {access_token}" # Get by name with fields -curl "{base_url}/api/v1/containers/name/s3_datalake.analytics-bucket?fields=owners,tags,dataModel,children" \ +curl "{base_url}/api/v1/containers/name/s3_datalake.analytics-bucket?fields=owners,tags,dataModel" \ -H "Authorization: Bearer {access_token}" ``` @@ -207,7 +211,7 @@ Returns a container object with all requested fields populated. - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -224,10 +228,6 @@ Returns a container object with all requested fields populated. - - Nested child containers. Only included when `fields` contains `children`. - - Version number for the entity. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/update.mdx index 7e81596ae..a968da596 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/update.mdx @@ -20,7 +20,7 @@ Update a container's properties using JSON Merge Patch. You can update by ID or Use `PATCH /v1/containers/name/{fqn}` to update by fully qualified name. - Fully qualified name of the container (e.g., `s3_datalake.analytics-bucket`). + Fully qualified name of the container, for example `s3_datalake.analytics-bucket`. ## Body Parameters @@ -74,7 +74,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -88,17 +88,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -122,16 +122,18 @@ container.numberOfObjects = 175000 container.size = 6442450944 updated = Containers.update(container) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/containers/{id} -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.schema.entity.data.Container; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var container = Containers.retrieve("14744329-85c2-499e-b1fa-249fb8162341"); +Container container = client.containers().get("14744329-85c2-499e-b1fa-249fb8162341"); container.setDescription("Updated: Primary analytics bucket with partitioned parquet data"); -var updated = Containers.update(container); +Container updated = client.containers().update("14744329-85c2-499e-b1fa-249fb8162341", container); ``` ```bash PATCH /v1/containers/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/versions.mdx index 0a21c1351..711b51e0f 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/containers/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/containers/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/containers/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Containers @@ -40,28 +42,30 @@ configure( # List all versions versions = Containers.get_versions("14744329-85c2-499e-b1fa-249fb8162341") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version container_v1 = Containers.get_specific_version( "14744329-85c2-499e-b1fa-249fb8162341", "0.1" ) -print(f"Original description: {container_v1.description}") +print(f"Original description: {container_v1.description.root if container_v1.description else None}") ``` ```java GET /v1/containers/{id}/versions -import static org.openmetadata.sdk.fluent.Containers.*; +import org.openmetadata.schema.entity.data.Container; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Containers.getVersions("14744329-85c2-499e-b1fa-249fb8162341"); +EntityHistory history = client.containers().getVersionList("14744329-85c2-499e-b1fa-249fb8162341"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = Containers.getSpecificVersion( +Container v1 = client.containers().getVersion( "14744329-85c2-499e-b1fa-249fb8162341", 0.1 ); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/create.mdx index 71cb5b5cb..480b48640 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/create.mdx @@ -16,7 +16,7 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Type of dashboard service (e.g., `Superset`, `Looker`, `Tableau`, `Metabase`, `Redash`, `PowerBI`, `Mode`, `QlikSense`, `QlikCloud`, `Lightdash`, `DomoDashboard`, `CustomDashboard`). + Type of dashboard service, for example `Superset`, `Looker`, `Tableau`, `Metabase`, `Redash`, `PowerBI`, `Mode`, `QlikSense`, `QlikCloud`, `Lightdash`, `DomoDashboard`, `CustomDashboard`. @@ -32,7 +32,7 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Service-specific connection configuration (e.g., hostPort, username, password for Superset). + Service-specific connection configuration, for example hostPort, username, password for Superset. @@ -46,7 +46,7 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new dashboard service connection to a platform such as Superset, Looker - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new dashboard service connection to a platform such as Superset, Looker - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -112,16 +112,26 @@ print(f"Created: {service['fullyQualifiedName']}") ``` ```java POST /v1/services/dashboardServices -import static org.openmetadata.sdk.fluent.DashboardServices.*; - -DashboardService service = DashboardServices.builder() - .name("sample_looker") - .serviceType("Looker") - .connection(lookerConnection() - .clientId("your-client-id") - .clientSecret("***") - .hostPort("https://looker.example.com:443")) - .create(); +import org.openmetadata.schema.api.data.CreateDashboardDataModel.DashboardServiceType; +import org.openmetadata.schema.api.services.CreateDashboardService; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.schema.services.connections.dashboard.LookerConnection; +import org.openmetadata.schema.type.DashboardConnection; +import org.openmetadata.sdk.fluent.DashboardServices; +import java.net.URI; + +CreateDashboardService request = new CreateDashboardService() + .withName("sample_looker") + .withDisplayName("Sample Looker") + .withServiceType(DashboardServiceType.Looker) + .withDescription("Production Looker instance") + .withConnection(new DashboardConnection().withConfig( + new LookerConnection() + .withClientId("your-client-id") + .withClientSecret("***") + .withHostPort(URI.create("https://looker.example.com:443")))); + +DashboardService service = DashboardServices.create(request); ``` ```bash POST /v1/services/dashboardServices @@ -201,7 +211,7 @@ Returns the created dashboard service object with all specified properties and s - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. @@ -223,7 +233,7 @@ Returns the created dashboard service object with all specified properties and s - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -232,7 +242,7 @@ Returns the created dashboard service object with all specified properties and s - + Fully qualified name of the assigned domain. @@ -245,11 +255,11 @@ Returns the created dashboard service object with all specified properties and s - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/delete.mdx index de55ba160..d5885b92e 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/delete.mdx @@ -28,7 +28,7 @@ Delete a dashboard service by ID or fully qualified name. Supports soft delete ( Use `DELETE /v1/services/dashboardServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. @@ -84,7 +84,10 @@ response = requests.put( ``` ```java DELETE /v1/services/dashboardServices/{id} -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.fluent.DashboardServices; + +// client is an initialized OpenMetadataClient. // Soft delete DashboardServices.delete("2c0c7c05-d820-4bea-a471-047deb7f92fd").execute(); @@ -94,11 +97,12 @@ DashboardServices.delete("2c0c7c05-d820-4bea-a471-047deb7f92fd") .hardDelete() .execute(); -// Delete by name -DashboardServices.deleteByName("sample_looker").execute(); +// Delete by name (look up the ID first) +DashboardService service = DashboardServices.retrieveByName("sample_looker"); +DashboardServices.delete(service.getId()).execute(); -// Restore -DashboardServices.restore("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +// Restore. The fluent class has no restore method, so use the client service. +client.dashboardServices().restore("2c0c7c05-d820-4bea-a471-047deb7f92fd"); ``` ```bash DELETE /v1/services/dashboardServices/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/import-export.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/import-export.mdx index 338b3d2db..04fdd6f38 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/import-export.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/import-export.mdx @@ -14,7 +14,7 @@ Export dashboard service metadata (dashboards, charts, owners, tags) to CSV and `GET /v1/services/dashboardServices/name/{fqn}/export` - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. ## Export Async @@ -88,38 +88,6 @@ response = requests.put( ) ``` -```java GET /v1/services/dashboardServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.DashboardServices; - -// Synchronous export -String csvData = DashboardServices.exportCsv("sample_looker") - .execute(); - -// Async export -String jobId = DashboardServices.exportCsv("sample_looker") - .async() - .execute(); - -// Synchronous import (dry run) -String result = DashboardServices.importCsv("sample_looker") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = DashboardServices.importCsv("sample_looker") - .withData(csvData) - .dryRun(false) - .execute(); - -// Async import -String jobId = DashboardServices.importCsv("sample_looker") - .withData(csvData) - .dryRun(false) - .async() - .execute(); -``` - ```bash GET /v1/services/dashboardServices/name/{fqn}/export # Export to CSV curl "{base_url}/api/v1/services/dashboardServices/name/sample_looker/export" \ diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/list.mdx index b5bbfb9a6..3bae0ef39 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/list.mdx @@ -59,22 +59,23 @@ response = requests.get( ``` ```java GET /v1/services/dashboardServices -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = DashboardServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.dashboardServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (DashboardService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } // With fields -var result = DashboardServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); +ListResponse withFields = client.dashboardServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/dashboardServices @@ -144,7 +145,7 @@ Returns a paginated list of dashboard service objects. By default, only basic fi - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/retrieve.mdx index 2aba0a945..0703ad50a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single dashboard service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single dashboard service by its unique ID or fully qualified name. Use `GET /v1/services/dashboardServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. @@ -71,22 +71,23 @@ response = requests.get( ``` ```java GET /v1/services/dashboardServices/{id} -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.fluent.DashboardServices; // Get by ID -var svc = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +DashboardService service = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); // Get by ID with fields -var svc = DashboardServices.retrieve( +DashboardService serviceWithFields = DashboardServices.retrieve( "2c0c7c05-d820-4bea-a471-047deb7f92fd", "owners,tags,domains" ); // Get by fully qualified name -var svc = DashboardServices.retrieveByName("sample_looker"); +DashboardService serviceByName = DashboardServices.retrieveByName("sample_looker"); // Get by name with fields -var svc = DashboardServices.retrieveByName("sample_looker", "owners,tags,domains"); +DashboardService serviceByNameWithFields = DashboardServices.retrieveByName("sample_looker", "owners,tags,domains"); ``` ```bash GET /v1/services/dashboardServices/{id} @@ -156,7 +157,7 @@ Returns a dashboard service object with all requested fields populated. - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/update.mdx index 902695aa5..f9a9defc4 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/update.mdx @@ -20,7 +20,7 @@ Update a dashboard service's properties using JSON Merge Patch. You can update b Use `PATCH /v1/services/dashboardServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the dashboard service (e.g., `sample_looker`). + Fully qualified name of the dashboard service, for example `sample_looker`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -108,12 +108,13 @@ print(f"Updated to version {service['version']}") ``` ```java PATCH /v1/services/dashboardServices/{id} -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.sdk.fluent.DashboardServices; // Retrieve, modify, and update -var svc = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); -svc.setDescription("Updated Looker production instance"); -var updated = DashboardServices.update(svc); +DashboardService service = DashboardServices.retrieve("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +service.setDescription("Updated Looker production instance"); +DashboardService updated = DashboardServices.update(service); ``` ```bash PATCH /v1/services/dashboardServices/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/versions.mdx index c9b41cc49..9f92d6666 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboard-services/versions.mdx @@ -24,7 +24,7 @@ Use `GET /v1/services/dashboardServices/{id}/versions/{version}` to retrieve a s - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. @@ -54,20 +54,20 @@ response = requests.get( ``` ```java GET /v1/services/dashboardServices/{id}/versions -import static org.openmetadata.sdk.fluent.DashboardServices.*; +import org.openmetadata.schema.entity.services.DashboardService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = DashboardServices.getVersions("2c0c7c05-d820-4bea-a471-047deb7f92fd"); +EntityHistory history = client.dashboardServices().getVersionList("2c0c7c05-d820-4bea-a471-047deb7f92fd"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = DashboardServices.getSpecificVersion( - "2c0c7c05-d820-4bea-a471-047deb7f92fd", - 0.1 -); +DashboardService v1 = client.dashboardServices().getVersion("2c0c7c05-d820-4bea-a471-047deb7f92fd", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/create.mdx index 28db09886..94d7c821d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/create.mdx @@ -16,7 +16,7 @@ Create a new dashboard within a dashboard service. - Fully qualified name of the parent DashboardService (e.g., `sample_superset`). + Fully qualified name of the parent DashboardService, for example `sample_superset`. @@ -44,7 +44,7 @@ Create a new dashboard within a dashboard service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -53,8 +53,8 @@ Create a new dashboard within a dashboard service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -66,11 +66,11 @@ Create a new dashboard within a dashboard service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -99,20 +99,23 @@ request = CreateDashboardRequest( ) dashboard = Dashboards.create(request) -print(f"Created: {dashboard.fullyQualifiedName}") +print(f"Created: {dashboard.fullyQualifiedName.root}") ``` ```java POST /v1/dashboards -import static org.openmetadata.sdk.fluent.Dashboards.*; - -// Create using builder pattern -var dashboard = Dashboards.builder() - .name("10") - .displayName("deck.gl Demo") - .service("sample_superset") - .description("Dashboard showcasing deck.gl visualizations") - .sourceUrl("http://localhost:808/superset/dashboard/10/") - .create(); +import org.openmetadata.schema.api.data.CreateDashboard; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. + +CreateDashboard request = new CreateDashboard() + .withName("10") + .withDisplayName("deck.gl Demo") + .withService("sample_superset") + .withDescription("Dashboard showcasing deck.gl visualizations") + .withSourceUrl("http://localhost:808/superset/dashboard/10/"); + +Dashboard dashboard = client.dashboards().create(request); ``` ```bash POST /v1/dashboards @@ -219,7 +222,7 @@ Returns the created dashboard object with all specified properties and system-ge - Type of dashboard service (e.g., Superset, Looker, Tableau, Metabase, PowerBI). + Type of dashboard service, for example Superset, Looker, Tableau, Metabase, PowerBI. @@ -235,7 +238,7 @@ Returns the created dashboard object with all specified properties and system-ge - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -257,11 +260,11 @@ Returns the created dashboard object with all specified properties and system-ge - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/delete.mdx index fdff6d9f5..0fce19cce 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/delete.mdx @@ -28,7 +28,7 @@ Delete a dashboard by ID or fully qualified name. Supports soft delete (default) Use `DELETE /v1/dashboards/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the dashboard (e.g., `sample_superset.10`). + Fully qualified name of the dashboard, for example `sample_superset.10`. @@ -66,36 +66,40 @@ Dashboards.delete( hard_delete=True ) -# Delete by name -Dashboards.delete_by_name("sample_superset.10") +# Delete by name (look up the ID first) +entity = Dashboards.retrieve_by_name("sample_superset.10") +Dashboards.delete(entity.id) # Delete by name with options -Dashboards.delete_by_name( - "sample_superset.10", - hard_delete=True -) +entity = Dashboards.retrieve_by_name("sample_superset.10") +Dashboards.delete(entity.id, hard_delete=True) # Restore a soft-deleted dashboard Dashboards.restore("03fb5cc3-de48-423f-9926-8e192e5de59d") ``` ```java DELETE /v1/dashboards/{id} -import static org.openmetadata.sdk.fluent.Dashboards.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -Dashboards.delete("03fb5cc3-de48-423f-9926-8e192e5de59d").execute(); +client.dashboards().delete("03fb5cc3-de48-423f-9926-8e192e5de59d"); // Hard delete -Dashboards.delete("03fb5cc3-de48-423f-9926-8e192e5de59d") - .hardDelete() - .execute(); +client.dashboards().delete("03fb5cc3-de48-423f-9926-8e192e5de59d", Map.of("hardDelete", "true")); // Delete by name -Dashboards.deleteByName("sample_superset.10") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/dashboards/name/sample_superset.10", + null, + Void.class +); // Restore -Dashboards.restore("03fb5cc3-de48-423f-9926-8e192e5de59d"); +client.dashboards().restore("03fb5cc3-de48-423f-9926-8e192e5de59d"); ``` ```bash DELETE /v1/dashboards/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/followers-votes.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/followers-votes.mdx index d13baa472..686650713 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/followers-votes.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/followers-votes.mdx @@ -51,7 +51,7 @@ Manage followers and votes for dashboard entities. ```python PUT /v1/dashboards/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Dashboards configure( @@ -59,39 +59,62 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + dashboard_id = "03fb5cc3-de48-423f-9926-8e192e5de59d" user_id = "user-uuid-here" # Add a follower dashboard = Dashboards.add_followers(dashboard_id, [user_id]) -print(f"Followers: {len(dashboard.followers)}") +print(f"Followers: {len(dashboard.followers.root)}") # Remove a follower dashboard = Dashboards.remove_followers(dashboard_id, [user_id]) # Add a vote -dashboard = Dashboards.add_vote(dashboard_id, vote_type="votedUp") +rest.put(f"/dashboards/{dashboard_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -dashboard = Dashboards.remove_vote(dashboard_id) +rest.put(f"/dashboards/{dashboard_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/dashboards/{id}/followers -import static org.openmetadata.sdk.fluent.Dashboards.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String dashboardId = "03fb5cc3-de48-423f-9926-8e192e5de59d"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; // Add a follower -Dashboards.addFollower(dashboardId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/dashboards/" + dashboardId + "/followers", + UUID.fromString(userId) +); // Remove a follower -Dashboards.removeFollower(dashboardId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/dashboards/" + dashboardId + "/followers/" + userId, + null +); // Add a vote -Dashboards.vote(dashboardId, "votedUp"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/dashboards/" + dashboardId + "/vote", + Map.of("updatedVoteType", "votedUp") +); // Remove a vote -Dashboards.vote(dashboardId, "unVoted"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/dashboards/" + dashboardId + "/vote", + Map.of("updatedVoteType", "unVoted") +); ``` ```bash PUT /v1/dashboards/{id}/followers diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/list.mdx index 70171ee6e..22fc27e9a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/list.mdx @@ -47,49 +47,54 @@ configure( # List first page dashboards = Dashboards.list(limit=50) -for d in dashboards.data: - print(f"{d.fullyQualifiedName}") +for d in dashboards.entities: + print(f"{d.fullyQualifiedName.root}") # List all with auto-pagination for d in Dashboards.list_all(): - print(f"{d.fullyQualifiedName}") + print(f"{d.fullyQualifiedName.root}") # Filter by service dashboards = Dashboards.list( - service="sample_superset", + filters={"service": "sample_superset"}, fields=["owners", "tags", "charts"], limit=50 ) -for d in dashboards.data: - print(f"{d.fullyQualifiedName}") +for d in dashboards.entities: + print(f"{d.fullyQualifiedName.root}") if d.owners: - print(f" Owners: {[o.name for o in d.owners]}") + print(f" Owners: {[o.name for o in d.owners.root]}") if d.tags: - print(f" Tags: {[t.tagFQN for t in d.tags]}") + print(f" Tags: {[t.tagFQN.root for t in d.tags]}") ``` ```java GET /v1/dashboards -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. // List first page -var result = Dashboards.list() - .limit(50) - .execute(); +ListResponse firstPage = client.dashboards().list( + new ListParams().setLimit(50) +); -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +for (Dashboard dashboard : firstPage.getData()) { + System.out.println(dashboard.getFullyQualifiedName()); } // Filter by service with fields -var result = Dashboards.list() - .service("sample_superset") - .fields("owners", "tags", "charts") - .limit(50) - .execute(); - -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +ListResponse filtered = client.dashboards().list( + new ListParams() + .setService("sample_superset") + .setFields("owners,tags,charts") + .setLimit(50) +); + +for (Dashboard dashboard : filtered.getData()) { + System.out.println(dashboard.getFullyQualifiedName()); } ``` @@ -191,7 +196,7 @@ Returns a paginated list of dashboard objects. By default, only basic fields are - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/retrieve.mdx index 482070f33..75f6f4246 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/retrieve.mdx @@ -16,7 +16,7 @@ Get a single dashboard by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,charts,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,charts,sourceHash`. @@ -28,7 +28,7 @@ Get a single dashboard by its unique ID or fully qualified name. Use `GET /v1/dashboards/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the dashboard (e.g., `sample_superset.10`). + Fully qualified name of the dashboard, for example `sample_superset.10`. @@ -51,7 +51,7 @@ configure( # Get by ID dashboard = Dashboards.retrieve("03fb5cc3-de48-423f-9926-8e192e5de59d") -print(f"{dashboard.fullyQualifiedName}: {dashboard.displayName}") +print(f"{dashboard.fullyQualifiedName.root}: {dashboard.displayName}") # Get by ID with fields dashboard = Dashboards.retrieve( @@ -70,22 +70,26 @@ dashboard = Dashboards.retrieve_by_name( ``` ```java GET /v1/dashboards/{id} -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. // Get by ID -var dashboard = Dashboards.retrieve("03fb5cc3-de48-423f-9926-8e192e5de59d"); +Dashboard dashboard = client.dashboards().get("03fb5cc3-de48-423f-9926-8e192e5de59d"); // Get by ID with fields -var dashboard = Dashboards.retrieve( +Dashboard dashboardWithFields = client.dashboards().get( "03fb5cc3-de48-423f-9926-8e192e5de59d", "owners,tags,charts" ); // Get by fully qualified name -var dashboard = Dashboards.retrieveByName("sample_superset.10"); +Dashboard dashboardByName = client.dashboards().getByName( + "sample_superset.10" +); // Get by name with fields -var dashboard = Dashboards.retrieveByName( +Dashboard dashboardByNameWithFields = client.dashboards().getByName( "sample_superset.10", "owners,tags,charts,domains" ); @@ -207,7 +211,7 @@ Returns a dashboard object with all requested fields populated. - Type of dashboard service (e.g., Superset, Looker, Tableau). + Type of dashboard service, for example Superset, Looker, Tableau. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/update.mdx index 58fa8be74..9da6c6d1f 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/update.mdx @@ -20,7 +20,7 @@ Update a dashboard's properties using JSON Merge Patch. You can update by ID or Use `PATCH /v1/dashboards/name/{fqn}` to update by fully qualified name. - Fully qualified name of the dashboard (e.g., `sample_superset.10`). + Fully qualified name of the dashboard, for example `sample_superset.10`. ## Body Parameters @@ -52,7 +52,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,17 +66,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -99,16 +99,18 @@ dashboard.description = "Updated: deck.gl Demo dashboard with new visualizations dashboard.displayName = "deck.gl Demo v2" updated = Dashboards.update(dashboard) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dashboards/{id} -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.schema.entity.data.Dashboard; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var dashboard = Dashboards.retrieve("03fb5cc3-de48-423f-9926-8e192e5de59d"); +Dashboard dashboard = client.dashboards().get("03fb5cc3-de48-423f-9926-8e192e5de59d"); dashboard.setDescription("Updated: deck.gl Demo dashboard with new visualizations"); -var updated = Dashboards.update(dashboard); +Dashboard updated = client.dashboards().update("03fb5cc3-de48-423f-9926-8e192e5de59d", dashboard); ``` ```bash PATCH /v1/dashboards/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/versions.mdx index 4bce3046b..bc288b1f2 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/dashboards/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dashboards/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dashboards/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Dashboards @@ -40,28 +42,30 @@ configure( # List all versions versions = Dashboards.get_versions("03fb5cc3-de48-423f-9926-8e192e5de59d") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version dashboard_v1 = Dashboards.get_specific_version( "03fb5cc3-de48-423f-9926-8e192e5de59d", "0.1" ) -print(f"Original description: {dashboard_v1.description}") +print(f"Original description: {dashboard_v1.description.root if dashboard_v1.description else None}") ``` ```java GET /v1/dashboards/{id}/versions -import static org.openmetadata.sdk.fluent.Dashboards.*; +import org.openmetadata.schema.entity.data.Dashboard; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Dashboards.getVersions("03fb5cc3-de48-423f-9926-8e192e5de59d"); +EntityHistory history = client.dashboards().getVersionList("03fb5cc3-de48-423f-9926-8e192e5de59d"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = Dashboards.getSpecificVersion( +Dashboard v1 = client.dashboards().getVersion( "03fb5cc3-de48-423f-9926-8e192e5de59d", 0.1 ); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/advanced.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/advanced.mdx index b446aa8d4..fd8eb9e08 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/advanced.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/advanced.mdx @@ -53,19 +53,19 @@ Manage followers, votes, and profiler configuration for database schema entities ### Get Profiler Config -`GET /v1/databaseSchemas/{id}/profilerConfig` +`GET /v1/databaseSchemas/{id}/databaseSchemaProfilerConfig` ### Set Profiler Config -`PUT /v1/databaseSchemas/{id}/profilerConfig` +`PUT /v1/databaseSchemas/{id}/databaseSchemaProfilerConfig` ### Delete Profiler Config -`DELETE /v1/databaseSchemas/{id}/profilerConfig` +`DELETE /v1/databaseSchemas/{id}/databaseSchemaProfilerConfig` ```python PUT /v1/databaseSchemas/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import DatabaseSchemas configure( @@ -73,27 +73,30 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + schema_id = "770e8400-e29b-41d4-a716-446655440000" user_id = "user-uuid-here" # Add a follower schema = DatabaseSchemas.add_followers(schema_id, [user_id]) -print(f"Followers: {len(schema.followers)}") +print(f"Followers: {len(schema.followers.root)}") # Remove a follower schema = DatabaseSchemas.remove_followers(schema_id, [user_id]) # Add a vote -schema = DatabaseSchemas.add_vote(schema_id, vote_type="votedUp") +rest.put(f"/databaseSchemas/{schema_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -schema = DatabaseSchemas.remove_vote(schema_id) +rest.put(f"/databaseSchemas/{schema_id}/vote", json={"updatedVoteType": "unVoted"}) # Get profiler config -config = DatabaseSchemas.get_profiler_config(schema_id) +schema = DatabaseSchemas.retrieve(schema_id, fields=["databaseSchemaProfilerConfig"]) +print(schema.databaseSchemaProfilerConfig) # Set profiler config -DatabaseSchemas.set_profiler_config(schema_id, { +rest.put(f"/databaseSchemas/{schema_id}/databaseSchemaProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": { @@ -105,17 +108,72 @@ DatabaseSchemas.set_profiler_config(schema_id, { }) # Delete profiler config -DatabaseSchemas.delete_profiler_config(schema_id) +rest.delete(f"/databaseSchemas/{schema_id}/databaseSchemaProfilerConfig") ``` ```java PUT /v1/databaseSchemas/{id}/followers -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.schema.type.DatabaseSchemaProfilerConfig; +import org.openmetadata.sdk.network.HttpMethod; -String schemaId = "770e8400-e29b-41d4-a716-446655440000"; +// client is an initialized OpenMetadataClient. -// Followers - use REST client directly -// Votes and profiler config - use REST client directly -// See curl examples for request format +String schemaId = "770e8400-e29b-41d4-a716-446655440000"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; + +// Add a follower +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/followers", + UUID.fromString(userId) +); + +// Remove a follower +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databaseSchemas/" + schemaId + "/followers/" + userId, + null +); + +// Add a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/vote", + Map.of("updatedVoteType", "votedUp") +); + +// Remove a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/vote", + Map.of("updatedVoteType", "unVoted") +); + +// Get profiler config +DatabaseSchema schema = client.databaseSchemas().get(schemaId, "databaseSchemaProfilerConfig"); +DatabaseSchemaProfilerConfig profilerConfig = schema.getDatabaseSchemaProfilerConfig(); + +// Set profiler config +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databaseSchemas/" + schemaId + "/databaseSchemaProfilerConfig", + Map.of( + "profileSampleConfig", Map.of( + "sampleConfigType", "STATIC", + "config", Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE") + ), + "sampleDataCount", 200 + ) +); + +// Delete profiler config +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databaseSchemas/" + schemaId + "/databaseSchemaProfilerConfig", + null +); ``` ```bash PUT /v1/databaseSchemas/{id}/followers @@ -142,11 +200,11 @@ curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5 -d '{"updatedVoteType": "unVoted"}' # Get profiler config -curl "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/profilerConfig" \ +curl "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/databaseSchemaProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Set profiler config -curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/profilerConfig" \ +curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/databaseSchemaProfilerConfig" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -161,7 +219,7 @@ curl -X PUT "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5 }' # Delete profiler config -curl -X DELETE "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/profilerConfig" \ +curl -X DELETE "{base_url}/api/v1/databaseSchemas/f681432b-e66c-4096-a1cd-7771358c5323/databaseSchemaProfilerConfig" \ -H "Authorization: Bearer {access_token}" ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/create.mdx index aadc7cf93..41ee04af9 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/create.mdx @@ -28,7 +28,7 @@ Create a new database schema within a database. - Data retention period in ISO 8601 duration format (e.g., `P365D`). + Data retention period in ISO 8601 duration format, for example `P365D`. @@ -40,7 +40,7 @@ Create a new database schema within a database. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -49,8 +49,8 @@ Create a new database schema within a database. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -62,11 +62,11 @@ Create a new database schema within a database. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -95,15 +95,16 @@ request = CreateDatabaseSchemaRequest( ) schema = DatabaseSchemas.create(request) -print(f"Created: {schema.fullyQualifiedName}") +print(f"Created: {schema.fullyQualifiedName.root}") ``` ```java POST /v1/databaseSchemas -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.sdk.fluent.builders.DatabaseSchemaBuilder; -DatabaseSchema schema = DatabaseSchemas.builder() +DatabaseSchema schema = new DatabaseSchemaBuilder(client) .name("public") - .database("snowflake_prod.analytics") + .databaseFQN("snowflake_prod.analytics") .create(); ``` @@ -229,7 +230,7 @@ Returns the created database schema object with all specified properties and sys - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -245,7 +246,7 @@ Returns the created database schema object with all specified properties and sys - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -267,11 +268,11 @@ Returns the created database schema object with all specified properties and sys - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/delete.mdx index 2cc2da242..ef90c0938 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/delete.mdx @@ -28,7 +28,7 @@ Delete a database schema by ID or fully qualified name. Supports soft delete (de Use `DELETE /v1/databaseSchemas/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the schema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the schema, for example `snowflake_prod.analytics.public`. @@ -67,31 +67,28 @@ DatabaseSchemas.delete( hard_delete=True ) -# Delete by name -DatabaseSchemas.delete_by_name("snowflake_prod.analytics.public") +# Delete by name (look up the ID first) +entity = DatabaseSchemas.retrieve_by_name("snowflake_prod.analytics.public") +DatabaseSchemas.delete(entity.id) # Delete by name with options -DatabaseSchemas.delete_by_name( - "snowflake_prod.analytics.public", - recursive=True, - hard_delete=True -) +entity = DatabaseSchemas.retrieve_by_name("snowflake_prod.analytics.public") +DatabaseSchemas.delete(entity.id, recursive=True, hard_delete=True) # Restore a soft-deleted schema DatabaseSchemas.restore("770e8400-e29b-41d4-a716-446655440000") ``` ```java DELETE /v1/databaseSchemas/{id} -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. // Soft delete -DatabaseSchemas.delete("770e8400-e29b-41d4-a716-446655440000").execute(); +client.databaseSchemas().delete("770e8400-e29b-41d4-a716-446655440000"); // Hard delete with recursive -DatabaseSchemas.delete("770e8400-e29b-41d4-a716-446655440000") - .recursive() - .hardDelete() - .execute(); +client.databaseSchemas().delete("770e8400-e29b-41d4-a716-446655440000", Map.of("recursive", "true", "hardDelete", "true")); ``` ```bash DELETE /v1/databaseSchemas/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/import-export.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/import-export.mdx index 7c1e7ffe5..a9237a69d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/import-export.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/import-export.mdx @@ -14,7 +14,7 @@ Export database schema metadata (tables, owners, tags) to CSV and import changes `GET /v1/databaseSchemas/name/{fqn}/export` - Fully qualified name of the schema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the schema, for example `snowflake_prod.analytics.public`. ## Export Async @@ -88,17 +88,19 @@ result = ( ```java GET /v1/databaseSchemas/name/{fqn}/export import org.openmetadata.sdk.fluent.DatabaseSchemas; +DatabaseSchemas.setDefaultClient(client); + // Synchronous export String csvData = DatabaseSchemas.exportCsv("snowflake_prod.analytics.public") .execute(); // Async export -String jobId = DatabaseSchemas.exportCsv("snowflake_prod.analytics.public") +String exportJobId = DatabaseSchemas.exportCsv("snowflake_prod.analytics.public") .async() .execute(); // Synchronous import (dry run) -String result = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") +String dryRunResult = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") .withData(csvData) .dryRun(true) .execute(); @@ -110,7 +112,7 @@ String result = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") .execute(); // Async import -String jobId = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") +String importJobId = DatabaseSchemas.importCsv("snowflake_prod.analytics.public") .withData(csvData) .dryRun(false) .async() diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/list.mdx index 3ced4ae73..cace5799f 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/list.mdx @@ -52,27 +52,32 @@ configure( # List with pagination page = DatabaseSchemas.list(limit=50, fields=["owners", "tags"]) for s in page.entities: - print(f"{s.fullyQualifiedName}") + print(f"{s.fullyQualifiedName.root}") if s.owners: - print(f" Owners: {[o.name for o in s.owners]}") + print(f" Owners: {[o.name for o in s.owners.root]}") # List all with auto-pagination all_schemas = DatabaseSchemas.list_all(batch_size=100) for schema in all_schemas: - print(f"{schema.fullyQualifiedName}") + print(f"{schema.fullyQualifiedName.root}") ``` ```java GET /v1/databaseSchemas -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // Retrieve by ID -DatabaseSchema schema = DatabaseSchemas.retrieve(schemaId); +DatabaseSchema schema = client.databaseSchemas().get(schemaId); // List schemas -var result = DatabaseSchemas.list() - .fields("owners", "tags") - .limit(50) - .execute(); +ListResponse result = client.databaseSchemas().list( + new ListParams() + .setFields("owners,tags") + .setLimit(50) +); for (DatabaseSchema s : result.getData()) { System.out.println(s.getFullyQualifiedName()); @@ -206,7 +211,7 @@ Returns a paginated list of database schema objects. By default, only basic fiel - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/retrieve.mdx index 5a4efdad7..d2ac7976b 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/retrieve.mdx @@ -28,7 +28,7 @@ Get a single database schema by its unique ID or fully qualified name. Use `GET /v1/databaseSchemas/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the schema (e.g., `Glue.default.information_schema`). + Fully qualified name of the schema, for example `Glue.default.information_schema`. @@ -51,7 +51,7 @@ configure( # Get by ID schema = DatabaseSchemas.retrieve("770e8400-e29b-41d4-a716-446655440000") -print(f"{schema.fullyQualifiedName}: {schema.description}") +print(f"{schema.fullyQualifiedName.root}: {schema.name.root}") # Get by ID with fields schema = DatabaseSchemas.retrieve( @@ -65,18 +65,20 @@ schema = DatabaseSchemas.retrieve_by_name("snowflake_prod.analytics.public") # Get by name with fields schema = DatabaseSchemas.retrieve_by_name( "snowflake_prod.analytics.public", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/databaseSchemas/{id} -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; + +// client is an initialized OpenMetadataClient. // Get by ID -DatabaseSchema schema = DatabaseSchemas.retrieve("770e8400-e29b-41d4-a716-446655440000"); +DatabaseSchema schema = client.databaseSchemas().get("770e8400-e29b-41d4-a716-446655440000"); // Get by fully qualified name -DatabaseSchema schema = DatabaseSchemas.retrieveByName("snowflake_prod.analytics.public"); +DatabaseSchema schemaByName = client.databaseSchemas().getByName("snowflake_prod.analytics.public"); ``` ```bash GET /v1/databaseSchemas/{id} @@ -230,7 +232,7 @@ Returns a database schema object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/update.mdx index 360f5b1e3..2df2cd726 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/update.mdx @@ -20,7 +20,7 @@ Update a database schema's properties using JSON Merge Patch. You can update by Use `PATCH /v1/databaseSchemas/name/{fqn}` to update by fully qualified name. - Fully qualified name of the schema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the schema, for example `snowflake_prod.analytics.public`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,11 +58,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -71,8 +71,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. Updated retention period in ISO 8601 duration format. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -95,16 +95,18 @@ schema.description = "Updated public schema for analytics" schema.retentionPeriod = "P730D" updated = DatabaseSchemas.update(schema) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/databaseSchemas/{id} -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -DatabaseSchema schema = DatabaseSchemas.retrieve("770e8400-e29b-41d4-a716-446655440000"); +DatabaseSchema schema = client.databaseSchemas().get("770e8400-e29b-41d4-a716-446655440000"); schema.setDescription("Updated public schema for analytics"); -DatabaseSchema updated = DatabaseSchemas.update(schema); +DatabaseSchema updated = client.databaseSchemas().update("770e8400-e29b-41d4-a716-446655440000", schema); ``` ```bash PATCH /v1/databaseSchemas/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/versions.mdx index 076951d20..57d2608eb 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-schemas/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/databaseSchemas/{id}/versions/{version}` to retrieve a specific ver - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/databaseSchemas/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import DatabaseSchemas @@ -40,26 +42,30 @@ configure( # List all versions versions = DatabaseSchemas.get_versions("770e8400-e29b-41d4-a716-446655440000") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version schema_v1 = DatabaseSchemas.get_specific_version( "770e8400-e29b-41d4-a716-446655440000", "0.1" ) -print(f"Original description: {schema_v1.description}") +print(f"Original description: {schema_v1.description.root if schema_v1.description else None}") ``` ```java GET /v1/databaseSchemas/{id}/versions -import static org.openmetadata.sdk.fluent.DatabaseSchemas.*; +import org.openmetadata.schema.entity.data.DatabaseSchema; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = DatabaseSchemas.getVersions("770e8400-e29b-41d4-a716-446655440000"); +EntityHistory versions = client.databaseSchemas().getVersionList("770e8400-e29b-41d4-a716-446655440000"); // Get a specific version -DatabaseSchema v1 = DatabaseSchemas.getSpecificVersion( +DatabaseSchema v1 = client.databaseSchemas().getVersion( "770e8400-e29b-41d4-a716-446655440000", - "0.1" + 0.1 ); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/create.mdx index 06a17eafe..a6fff33ee 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/create.mdx @@ -16,7 +16,7 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Type of database service (e.g., `Snowflake`, `BigQuery`, `PostgreSQL`, `MySQL`, `Redshift`, `Databricks`). + Type of database service, for example `Snowflake`, `BigQuery`, `PostgreSQL`, `MySQL`, `Redshift`, `Databricks`. @@ -32,7 +32,7 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Service-specific connection configuration (e.g., account, warehouse, database for Snowflake). + Service-specific connection configuration, for example account, warehouse, database for Snowflake. @@ -46,7 +46,7 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new database service connection to a platform such as Snowflake, BigQue - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new database service connection to a platform such as Snowflake, BigQue - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -105,21 +105,30 @@ request = CreateDatabaseServiceRequest( ) service = DatabaseServices.create(request) -print(f"Created: {service.fullyQualifiedName}") +print(f"Created: {service.fullyQualifiedName.root}") ``` ```java POST /v1/services/databaseServices -import static org.openmetadata.sdk.fluent.DatabaseServices.*; - -DatabaseService service = DatabaseServices.builder() - .name("snowflake_prod") - .serviceType("Snowflake") - .connection(snowflakeConnection() - .account("xy12345.us-east-1") - .username("ingestion_user") - .warehouse("COMPUTE_WH") - .database("ANALYTICS")) - .create(); +import org.openmetadata.schema.api.services.CreateDatabaseService; +import org.openmetadata.schema.api.services.CreateDatabaseService.DatabaseServiceType; +import org.openmetadata.schema.api.services.DatabaseConnection; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.services.connections.database.SnowflakeConnection; +import org.openmetadata.sdk.fluent.DatabaseServices; + +CreateDatabaseService request = new CreateDatabaseService() + .withName("snowflake_prod") + .withServiceType(DatabaseServiceType.Snowflake) + .withDescription("Production Snowflake data warehouse") + .withConnection(new DatabaseConnection().withConfig( + new SnowflakeConnection() + .withAccount("xy12345.us-east-1") + .withUsername("ingestion_user") + .withPassword("***") + .withWarehouse("COMPUTE_WH") + .withDatabase("ANALYTICS"))); + +DatabaseService service = DatabaseServices.create(request); ``` ```bash POST /v1/services/databaseServices @@ -215,7 +224,7 @@ Returns the created database service object with all specified properties and sy - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -237,7 +246,7 @@ Returns the created database service object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -246,7 +255,7 @@ Returns the created database service object with all specified properties and sy - + Fully qualified name of the assigned domain. @@ -259,11 +268,11 @@ Returns the created database service object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/delete.mdx index 771abdd2d..0c1aee2b1 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/delete.mdx @@ -28,7 +28,7 @@ Delete a database service by ID or fully qualified name. Supports soft delete (d Use `DELETE /v1/services/databaseServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. @@ -68,11 +68,11 @@ DatabaseServices.delete( ) # Delete by name -DatabaseServices.delete_by_name("snowflake_prod") +DatabaseServices.delete(DatabaseServices.retrieve_by_name("snowflake_prod").id) # Delete by name with options -DatabaseServices.delete_by_name( - "snowflake_prod", +DatabaseServices.delete( + DatabaseServices.retrieve_by_name("snowflake_prod").id, recursive=True, hard_delete=True ) @@ -82,7 +82,8 @@ DatabaseServices.restore("a1b2c3d4-e5f6-7890-abcd-ef1234567890") ``` ```java DELETE /v1/services/databaseServices/{id} -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.fluent.DatabaseServices; // Soft delete DatabaseServices.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890").execute(); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/import-export.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/import-export.mdx index bfff3024c..925f07e5a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/import-export.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/import-export.mdx @@ -14,7 +14,7 @@ Export database service metadata (databases, schemas, owners, tags) to CSV and i `GET /v1/services/databaseServices/name/{fqn}/export` - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. ## Export Async @@ -86,35 +86,21 @@ result = ( ``` ```java GET /v1/services/databaseServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.DatabaseServices; - +// client is an initialized OpenMetadataClient. // Synchronous export -String csvData = DatabaseServices.exportCsv("snowflake_prod") - .execute(); +String csvData = client.databaseServices().exportCsv("snowflake_prod"); // Async export -String jobId = DatabaseServices.exportCsv("snowflake_prod") - .async() - .execute(); - -// Synchronous import (dry run) -String result = DatabaseServices.importCsv("snowflake_prod") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = DatabaseServices.importCsv("snowflake_prod") - .withData(csvData) - .dryRun(false) - .execute(); +String exportJob = client.databaseServices().exportCsvAsync("snowflake_prod"); + +// Import CSV (dry run first) +String dryRunResult = client.databaseServices().importCsv("snowflake_prod", csvData, true); + +// Apply the import +String result = client.databaseServices().importCsv("snowflake_prod", csvData, false); // Async import -String jobId = DatabaseServices.importCsv("snowflake_prod") - .withData(csvData) - .dryRun(false) - .async() - .execute(); +String importJob = client.databaseServices().importCsvAsync("snowflake_prod", csvData, false); ``` ```bash GET /v1/services/databaseServices/name/{fqn}/export diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/list.mdx index 5317ead18..305fe5109 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/list.mdx @@ -48,31 +48,34 @@ configure( # List with pagination page = DatabaseServices.list(limit=50, fields=["owners", "tags"]) for svc in page.entities: - print(f"{svc.name} ({svc.serviceType})") + print(f"{svc.name.root} ({svc.serviceType})") if svc.owners: - print(f" Owners: {[o.name for o in svc.owners]}") + print(f" Owners: {[o.name for o in svc.owners.root]}") # List all with auto-pagination all_services = DatabaseServices.list_all(batch_size=100) for service in all_services: - print(f"{service.fullyQualifiedName}") + print(f"{service.fullyQualifiedName.root}") ``` ```java GET /v1/services/databaseServices -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; -// Retrieve by ID -DatabaseService service = DatabaseServices.retrieve(serviceId); +// client is an initialized OpenMetadataClient. -// List services -var result = DatabaseServices.list() - .fields("owners", "tags") - .limit(50) - .execute(); +// List first page +ListResponse firstPage = client.databaseServices().list(new ListParams().setLimit(50)); -for (DatabaseService svc : result.getData()) { - System.out.println(svc.getName() + " (" + svc.getServiceType() + ")"); +for (DatabaseService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } + +// With fields +ListResponse withFields = client.databaseServices().list( + new ListParams().setFields("owners,tags").setLimit(50) +); ``` ```bash GET /v1/services/databaseServices @@ -190,7 +193,7 @@ Returns a paginated list of database service objects. By default, only basic fie - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/retrieve.mdx index 316fc13df..95fafb2cb 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/retrieve.mdx @@ -28,7 +28,7 @@ Get a single database service by its unique ID or fully qualified name. Use `GET /v1/services/databaseServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. @@ -51,7 +51,7 @@ configure( # Get by ID service = DatabaseServices.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890") -print(f"{service.fullyQualifiedName}: {service.serviceType}") +print(f"{service.fullyQualifiedName.root}: {service.serviceType}") # Get by ID with fields service = DatabaseServices.retrieve( @@ -65,18 +65,19 @@ service = DatabaseServices.retrieve_by_name("snowflake_prod") # Get by name with fields service = DatabaseServices.retrieve_by_name( "snowflake_prod", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/services/databaseServices/{id} -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.fluent.DatabaseServices; // Get by ID DatabaseService service = DatabaseServices.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Get by fully qualified name -DatabaseService service = DatabaseServices.retrieveByName("snowflake_prod"); +DatabaseService serviceByName = DatabaseServices.retrieveByName("snowflake_prod"); ``` ```bash GET /v1/services/databaseServices/{id} @@ -164,7 +165,7 @@ Returns a database service object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/update.mdx index 73829e8da..2a40b5461 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/update.mdx @@ -20,7 +20,7 @@ Update a database service's properties using JSON Merge Patch. You can update by Use `PATCH /v1/services/databaseServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the database service (e.g., `snowflake_prod`). + Fully qualified name of the database service, for example `snowflake_prod`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -97,11 +97,12 @@ service.description = "Updated production Snowflake warehouse" service.displayName = "Snowflake Prod (Updated)" updated = DatabaseServices.update(service) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/services/databaseServices/{id} -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.fluent.DatabaseServices; // Retrieve, modify, and update DatabaseService service = DatabaseServices.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/versions.mdx index e41aabe1b..ee1510466 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/database-services/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/services/databaseServices/{id}/versions/{version}` to retrieve a sp - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/services/databaseServices/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import DatabaseServices @@ -40,27 +42,32 @@ configure( # List all versions versions = DatabaseServices.get_versions("a1b2c3d4-e5f6-7890-abcd-ef1234567890") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version service_v1 = DatabaseServices.get_specific_version( "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "0.1" ) -print(f"Original description: {service_v1.description}") +print(f"Original description: {getattr(service_v1.description, 'root', service_v1.description)}") ``` ```java GET /v1/services/databaseServices/{id}/versions -import static org.openmetadata.sdk.fluent.DatabaseServices.*; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = DatabaseServices.getVersions("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +EntityHistory history = client.databaseServices().getVersionList("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); + +for (Object version : history.getVersions()) { + System.out.println("Version: " + version); +} // Get a specific version -DatabaseService v1 = DatabaseServices.getSpecificVersion( - "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "0.1" -); +DatabaseService v1 = client.databaseServices().getVersion("a1b2c3d4-e5f6-7890-abcd-ef1234567890", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/advanced.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/advanced.mdx index 9ae3b3f51..3f9bef554 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/advanced.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/advanced.mdx @@ -53,19 +53,19 @@ Manage followers, votes, and profiler configuration for database entities. ### Get Profiler Config -`GET /v1/databases/{id}/profilerConfig` +`GET /v1/databases/{id}/databaseProfilerConfig` ### Set Profiler Config -`PUT /v1/databases/{id}/profilerConfig` +`PUT /v1/databases/{id}/databaseProfilerConfig` ### Delete Profiler Config -`DELETE /v1/databases/{id}/profilerConfig` +`DELETE /v1/databases/{id}/databaseProfilerConfig` ```python PUT /v1/databases/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Databases configure( @@ -73,27 +73,30 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + database_id = "550e8400-e29b-41d4-a716-446655440000" user_id = "user-uuid-here" # Add a follower database = Databases.add_followers(database_id, [user_id]) -print(f"Followers: {len(database.followers)}") +print(f"Followers: {len(database.followers.root)}") # Remove a follower database = Databases.remove_followers(database_id, [user_id]) # Add a vote -database = Databases.add_vote(database_id, vote_type="votedUp") +rest.put(f"/databases/{database_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -database = Databases.remove_vote(database_id) +rest.put(f"/databases/{database_id}/vote", json={"updatedVoteType": "unVoted"}) # Get profiler config -config = Databases.get_profiler_config(database_id) +database = Databases.retrieve(database_id, fields=["databaseProfilerConfig"]) +print(database.databaseProfilerConfig) # Set profiler config -Databases.set_profiler_config(database_id, { +rest.put(f"/databases/{database_id}/databaseProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": { @@ -105,17 +108,72 @@ Databases.set_profiler_config(database_id, { }) # Delete profiler config -Databases.delete_profiler_config(database_id) +rest.delete(f"/databases/{database_id}/databaseProfilerConfig") ``` ```java PUT /v1/databases/{id}/followers -import static org.openmetadata.sdk.fluent.Databases.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.schema.type.DatabaseProfilerConfig; +import org.openmetadata.sdk.network.HttpMethod; -String databaseId = "550e8400-e29b-41d4-a716-446655440000"; +// client is an initialized OpenMetadataClient. -// Followers - use REST client directly -// Votes and profiler config - use REST client directly -// See curl examples for request format +String databaseId = "550e8400-e29b-41d4-a716-446655440000"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; + +// Add a follower +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/followers", + UUID.fromString(userId) +); + +// Remove a follower +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databases/" + databaseId + "/followers/" + userId, + null +); + +// Add a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/vote", + Map.of("updatedVoteType", "votedUp") +); + +// Remove a vote +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/vote", + Map.of("updatedVoteType", "unVoted") +); + +// Get profiler config +Database database = client.databases().get(databaseId, "databaseProfilerConfig"); +DatabaseProfilerConfig profilerConfig = database.getDatabaseProfilerConfig(); + +// Set profiler config +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/databases/" + databaseId + "/databaseProfilerConfig", + Map.of( + "profileSampleConfig", Map.of( + "sampleConfigType", "STATIC", + "config", Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE") + ), + "sampleDataCount", 200 + ) +); + +// Delete profiler config +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/databases/" + databaseId + "/databaseProfilerConfig", + null +); ``` ```bash PUT /v1/databases/{id}/followers @@ -142,11 +200,11 @@ curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/vo -d '{"updatedVoteType": "unVoted"}' # Get profiler config -curl "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/profilerConfig" \ +curl "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/databaseProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Set profiler config -curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/profilerConfig" \ +curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/databaseProfilerConfig" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -161,7 +219,7 @@ curl -X PUT "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/pr }' # Delete profiler config -curl -X DELETE "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/profilerConfig" \ +curl -X DELETE "{base_url}/api/v1/databases/1d08c2c6-cea7-4adf-9043-0f6a6aaf9721/databaseProfilerConfig" \ -H "Authorization: Bearer {access_token}" ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/create.mdx index 104e9d412..a7bf8dbb5 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/create.mdx @@ -28,7 +28,7 @@ Create a new database within a database service. - Data retention period in ISO 8601 duration format (e.g., `P365D`). + Data retention period in ISO 8601 duration format, for example `P365D`. @@ -40,7 +40,7 @@ Create a new database within a database service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -49,8 +49,8 @@ Create a new database within a database service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -62,11 +62,11 @@ Create a new database within a database service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -95,15 +95,16 @@ request = CreateDatabaseRequest( ) database = Databases.create(request) -print(f"Created: {database.fullyQualifiedName}") +print(f"Created: {database.fullyQualifiedName.root}") ``` ```java POST /v1/databases -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.sdk.fluent.builders.DatabaseBuilder; -Database database = Databases.builder() +Database database = new DatabaseBuilder(client) .name("analytics") - .service("snowflake_prod") + .serviceFQN("snowflake_prod") .create(); ``` @@ -201,7 +202,7 @@ Returns the created database object with all specified properties and system-gen - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -217,7 +218,7 @@ Returns the created database object with all specified properties and system-gen - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -226,7 +227,7 @@ Returns the created database object with all specified properties and system-gen - + Fully qualified name of the assigned domain. @@ -239,11 +240,11 @@ Returns the created database object with all specified properties and system-gen - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/delete.mdx index d001ebc97..6078b6c5a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/delete.mdx @@ -28,7 +28,7 @@ Delete a database by ID or fully qualified name. Supports soft delete (default), Use `DELETE /v1/databases/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the database (e.g., `snowflake_prod.analytics`). + Fully qualified name of the database, for example `snowflake_prod.analytics`. @@ -67,31 +67,28 @@ Databases.delete( hard_delete=True ) -# Delete by name -Databases.delete_by_name("snowflake_prod.analytics") +# Delete by name (look up the ID first) +entity = Databases.retrieve_by_name("snowflake_prod.analytics") +Databases.delete(entity.id) # Delete by name with options -Databases.delete_by_name( - "snowflake_prod.analytics", - recursive=True, - hard_delete=True -) +entity = Databases.retrieve_by_name("snowflake_prod.analytics") +Databases.delete(entity.id, recursive=True, hard_delete=True) # Restore a soft-deleted database Databases.restore("550e8400-e29b-41d4-a716-446655440000") ``` ```java DELETE /v1/databases/{id} -import static org.openmetadata.sdk.fluent.Databases.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. // Soft delete -Databases.delete("550e8400-e29b-41d4-a716-446655440000").execute(); +client.databases().delete("550e8400-e29b-41d4-a716-446655440000"); // Hard delete with recursive -Databases.delete("550e8400-e29b-41d4-a716-446655440000") - .recursive() - .hardDelete() - .execute(); +client.databases().delete("550e8400-e29b-41d4-a716-446655440000", Map.of("recursive", "true", "hardDelete", "true")); ``` ```bash DELETE /v1/databases/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/import-export.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/import-export.mdx index afd59678e..ce6cc0dbd 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/import-export.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/import-export.mdx @@ -14,7 +14,7 @@ Export database metadata (schemas, tables, owners, tags) to CSV and import chang `GET /v1/databases/name/{fqn}/export` - Fully qualified name of the database (e.g., `snowflake_prod.analytics`). + Fully qualified name of the database, for example `snowflake_prod.analytics`. ## Export Async @@ -88,17 +88,19 @@ result = ( ```java GET /v1/databases/name/{fqn}/export import org.openmetadata.sdk.fluent.Databases; +Databases.setDefaultClient(client); + // Synchronous export String csvData = Databases.exportCsv("snowflake_prod.analytics") .execute(); // Async export -String jobId = Databases.exportCsv("snowflake_prod.analytics") +String exportJobId = Databases.exportCsv("snowflake_prod.analytics") .async() .execute(); // Synchronous import (dry run) -String result = Databases.importCsv("snowflake_prod.analytics") +String dryRunResult = Databases.importCsv("snowflake_prod.analytics") .withData(csvData) .dryRun(true) .execute(); @@ -110,7 +112,7 @@ String result = Databases.importCsv("snowflake_prod.analytics") .execute(); // Async import -String jobId = Databases.importCsv("snowflake_prod.analytics") +String importJobId = Databases.importCsv("snowflake_prod.analytics") .withData(csvData) .dryRun(false) .async() diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/list.mdx index 4fd9170c0..34ca00f2f 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/list.mdx @@ -52,27 +52,32 @@ configure( # List with pagination page = Databases.list(limit=50, fields=["owners", "tags"]) for db in page.entities: - print(f"{db.fullyQualifiedName}") + print(f"{db.fullyQualifiedName.root}") if db.owners: - print(f" Owners: {[o.name for o in db.owners]}") + print(f" Owners: {[o.name for o in db.owners.root]}") # List all with auto-pagination all_databases = Databases.list_all(batch_size=100) for database in all_databases: - print(f"{database.fullyQualifiedName}") + print(f"{database.fullyQualifiedName.root}") ``` ```java GET /v1/databases -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // Retrieve by ID -Database database = Databases.retrieve(databaseId); +Database database = client.databases().get(databaseId); // List databases -var result = Databases.list() - .fields("owners", "tags") - .limit(50) - .execute(); +ListResponse result = client.databases().list( + new ListParams() + .setFields("owners,tags") + .setLimit(50) +); for (Database db : result.getData()) { System.out.println(db.getFullyQualifiedName()); @@ -181,7 +186,7 @@ Returns a paginated list of database objects. By default, only basic fields are - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -192,8 +197,8 @@ Returns a paginated list of database objects. By default, only basic fields are Classification tags applied to the database. Only included when `fields` contains `tags`. - - Domain assignment for governance. Only included when `fields` contains `domain`. + + Domain assignment for governance. Only included when `fields` contains `domains`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/retrieve.mdx index 06132894b..75a554830 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/retrieve.mdx @@ -28,7 +28,7 @@ Get a single database by its unique ID or fully qualified name. Use `GET /v1/databases/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the database (e.g., `mysql_sample.default`). + Fully qualified name of the database, for example `mysql_sample.default`. @@ -51,7 +51,7 @@ configure( # Get by ID database = Databases.retrieve("550e8400-e29b-41d4-a716-446655440000") -print(f"{database.fullyQualifiedName}: {database.description}") +print(f"{database.fullyQualifiedName.root}: {database.name.root}") # Get by ID with fields database = Databases.retrieve( @@ -65,18 +65,20 @@ database = Databases.retrieve_by_name("snowflake_prod.analytics") # Get by name with fields database = Databases.retrieve_by_name( "snowflake_prod.analytics", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/databases/{id} -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; + +// client is an initialized OpenMetadataClient. // Get by ID -Database database = Databases.retrieve("550e8400-e29b-41d4-a716-446655440000"); +Database database = client.databases().get("550e8400-e29b-41d4-a716-446655440000"); // Get by fully qualified name -Database database = Databases.retrieveByName("snowflake_prod.analytics"); +Database databaseByName = client.databases().getByName("snowflake_prod.analytics"); ``` ```bash GET /v1/databases/{id} @@ -187,7 +189,7 @@ Returns a database object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -202,8 +204,8 @@ Returns a database object with all requested fields populated. Classification tags. Only included when `fields` contains `tags`. - - Domain assignment. Only included when `fields` contains `domain`. + + Domain assignment. Only included when `fields` contains `domains`. --- diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/update.mdx index 2c1492a8b..a18ad7e83 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/update.mdx @@ -20,7 +20,7 @@ Update a database's properties using JSON Merge Patch. You can update by ID or b Use `PATCH /v1/databases/name/{fqn}` to update by fully qualified name. - Fully qualified name of the database (e.g., `snowflake_prod.analytics`). + Fully qualified name of the database, for example `snowflake_prod.analytics`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,11 +58,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -71,8 +71,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. Updated retention period in ISO 8601 duration format. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -95,16 +95,18 @@ database.description = "Updated analytics data warehouse" database.retentionPeriod = "P730D" updated = Databases.update(database) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/databases/{id} -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -Database database = Databases.retrieve("550e8400-e29b-41d4-a716-446655440000"); +Database database = client.databases().get("550e8400-e29b-41d4-a716-446655440000"); database.setDescription("Updated analytics data warehouse"); -Database updated = Databases.update(database); +Database updated = client.databases().update("550e8400-e29b-41d4-a716-446655440000", database); ``` ```bash PATCH /v1/databases/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/versions.mdx index 536c721ce..af377eff8 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/databases/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/databases/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/databases/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Databases @@ -40,26 +42,30 @@ configure( # List all versions versions = Databases.get_versions("550e8400-e29b-41d4-a716-446655440000") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version database_v1 = Databases.get_specific_version( "550e8400-e29b-41d4-a716-446655440000", "0.1" ) -print(f"Original description: {database_v1.description}") +print(f"Original description: {database_v1.description.root if database_v1.description else None}") ``` ```java GET /v1/databases/{id}/versions -import static org.openmetadata.sdk.fluent.Databases.*; +import org.openmetadata.schema.entity.data.Database; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = Databases.getVersions("550e8400-e29b-41d4-a716-446655440000"); +EntityHistory versions = client.databases().getVersionList("550e8400-e29b-41d4-a716-446655440000"); // Get a specific version -Database v1 = Databases.getSpecificVersion( +Database v1 = client.databases().getVersion( "550e8400-e29b-41d4-a716-446655440000", - "0.1" + 0.1 ); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/create.mdx index 96bf6dabf..74298f429 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/create.mdx @@ -16,7 +16,7 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Type of messaging service (e.g., `Kafka`, `Redpanda`, `Kinesis`, `CustomMessaging`). + Type of messaging service, for example `Kafka`, `Redpanda`, `Kinesis`, `CustomMessaging`. @@ -32,7 +32,7 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Service-specific connection configuration (e.g., bootstrapServers, securityProtocol for Kafka). + Service-specific connection configuration, for example bootstrapServers, securityProtocol for Kafka. @@ -46,7 +46,7 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new messaging service connection to a platform such as Kafka, Redpanda, - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -114,16 +114,22 @@ print(f"Created: {service['fullyQualifiedName']}") ``` ```java POST /v1/services/messagingServices -import static org.openmetadata.sdk.fluent.MessagingServices.*; - -MessagingService service = MessagingServices.builder() - .name("sample_kafka") - .serviceType("Kafka") - .connection(kafkaConnection() - .bootstrapServers("localhost:9092") - .securityProtocol("PLAINTEXT") - .saslMechanism("PLAIN")) - .create(); +import org.openmetadata.schema.api.services.CreateMessagingService; +import org.openmetadata.schema.api.services.CreateMessagingService.MessagingServiceType; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.schema.services.connections.messaging.KafkaConnection; +import org.openmetadata.schema.type.MessagingConnection; +import org.openmetadata.sdk.fluent.MessagingServices; + +CreateMessagingService request = new CreateMessagingService() + .withName("sample_kafka") + .withServiceType(MessagingServiceType.Kafka) + .withConnection(new MessagingConnection().withConfig( + new KafkaConnection() + .withBootstrapServers("localhost:9092") + .withSecurityProtocol(KafkaConnection.SecurityProtocol.PLAINTEXT))); + +MessagingService service = MessagingServices.create(request); ``` ```bash POST /v1/services/messagingServices @@ -206,7 +212,7 @@ Returns the created messaging service object with all specified properties and s - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. @@ -228,7 +234,7 @@ Returns the created messaging service object with all specified properties and s - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -237,7 +243,7 @@ Returns the created messaging service object with all specified properties and s - + Fully qualified name of the assigned domain. @@ -250,11 +256,11 @@ Returns the created messaging service object with all specified properties and s - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/delete.mdx index c7a4bffb5..8310eaed0 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/delete.mdx @@ -28,7 +28,7 @@ Delete a messaging service by ID or fully qualified name. Supports soft delete ( Use `DELETE /v1/services/messagingServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. @@ -82,7 +82,8 @@ requests.put( ``` ```java DELETE /v1/services/messagingServices/{id} -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.fluent.MessagingServices; // Soft delete MessagingServices.delete("469ef25e-9bdf-4d5f-8553-eb0ce8581f30").execute(); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/import-export.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/import-export.mdx index df1aadd09..58a7b937c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/import-export.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/import-export.mdx @@ -14,7 +14,7 @@ Export messaging service metadata (topics, owners, tags) to CSV and import chang `GET /v1/services/messagingServices/name/{fqn}/export` - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. ## Export Async @@ -90,38 +90,6 @@ response = requests.put( ) ``` -```java GET /v1/services/messagingServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.MessagingServices; - -// Synchronous export -String csvData = MessagingServices.exportCsv("sample_kafka") - .execute(); - -// Async export -String jobId = MessagingServices.exportCsv("sample_kafka") - .async() - .execute(); - -// Synchronous import (dry run) -String result = MessagingServices.importCsv("sample_kafka") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = MessagingServices.importCsv("sample_kafka") - .withData(csvData) - .dryRun(false) - .execute(); - -// Async import -String jobId = MessagingServices.importCsv("sample_kafka") - .withData(csvData) - .dryRun(false) - .async() - .execute(); -``` - ```bash GET /v1/services/messagingServices/name/{fqn}/export # Export to CSV curl "{base_url}/api/v1/services/messagingServices/name/sample_kafka/export" \ diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/list.mdx index a6d62e380..0595a9ead 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/list.mdx @@ -61,17 +61,23 @@ response = requests.get( ``` ```java GET /v1/services/messagingServices -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; -// List services -var result = MessagingServices.list() - .fields("owners", "tags") - .limit(50) - .execute(); +// client is an initialized OpenMetadataClient. -for (MessagingService svc : result.getData()) { - System.out.println(svc.getName() + " (" + svc.getServiceType() + ")"); +// List first page +ListResponse firstPage = client.messagingServices().list(new ListParams().setLimit(50)); + +for (MessagingService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } + +// With fields +ListResponse withFields = client.messagingServices().list( + new ListParams().setFields("owners,tags").setLimit(50) +); ``` ```bash GET /v1/services/messagingServices @@ -155,7 +161,7 @@ Returns a paginated list of messaging service objects. By default, only basic fi - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/retrieve.mdx index 8a164f3f8..eb445df61 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/retrieve.mdx @@ -28,7 +28,7 @@ Get a single messaging service by its unique ID or fully qualified name. Use `GET /v1/services/messagingServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. @@ -76,13 +76,23 @@ response = requests.get( ``` ```java GET /v1/services/messagingServices/{id} -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.fluent.MessagingServices; // Get by ID MessagingService service = MessagingServices.retrieve("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); +// Get by ID with fields +MessagingService serviceWithFields = MessagingServices.retrieve( + "469ef25e-9bdf-4d5f-8553-eb0ce8581f30", + "owners,tags" +); + // Get by fully qualified name -MessagingService service = MessagingServices.retrieveByName("sample_kafka"); +MessagingService serviceByName = MessagingServices.retrieveByName("sample_kafka"); + +// Get by name with fields +MessagingService serviceByNameWithFields = MessagingServices.retrieveByName("sample_kafka", "owners,tags"); ``` ```bash GET /v1/services/messagingServices/{id} @@ -162,7 +172,7 @@ Returns a messaging service object with all requested fields populated. - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/update.mdx index 5cd79add9..13b894550 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/update.mdx @@ -20,7 +20,7 @@ Update a messaging service's properties using JSON Merge Patch. You can update b Use `PATCH /v1/services/messagingServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the messaging service (e.g., `sample_kafka`). + Fully qualified name of the messaging service, for example `sample_kafka`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -105,7 +105,8 @@ print(f"Updated to version {updated['version']}") ``` ```java PATCH /v1/services/messagingServices/{id} -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.sdk.fluent.MessagingServices; // Retrieve, modify, and update MessagingService service = MessagingServices.retrieve("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/versions.mdx index 59bd8e175..80c748e35 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/messaging-services/versions.mdx @@ -24,7 +24,7 @@ Use `GET /v1/services/messagingServices/{id}/versions/{version}` to retrieve a s - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. @@ -53,16 +53,20 @@ print(f"Original description: {service_v1.get('description')}") ``` ```java GET /v1/services/messagingServices/{id}/versions -import static org.openmetadata.sdk.fluent.MessagingServices.*; +import org.openmetadata.schema.entity.services.MessagingService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = MessagingServices.getVersions("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); +EntityHistory history = client.messagingServices().getVersionList("469ef25e-9bdf-4d5f-8553-eb0ce8581f30"); + +for (Object version : history.getVersions()) { + System.out.println("Version: " + version); +} // Get a specific version -MessagingService v1 = MessagingServices.getSpecificVersion( - "469ef25e-9bdf-4d5f-8553-eb0ce8581f30", - "0.1" -); +MessagingService v1 = client.messagingServices().getVersion("469ef25e-9bdf-4d5f-8553-eb0ce8581f30", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/create.mdx index 096cf9df1..b01d04484 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/create.mdx @@ -16,7 +16,7 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Type of ML model service (e.g., `Mlflow`, `Sklearn`, `SageMaker`, `CustomMlModel`). + Type of ML model service, for example `Mlflow`, `Sklearn`, `SageMaker`, `CustomMlModel`. @@ -24,7 +24,7 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Service-specific connection configuration (e.g., `trackingUri`, `registryUri` for Mlflow). + Service-specific connection configuration, for example `trackingUri`, `registryUri` for Mlflow. @@ -46,7 +46,7 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,24 +68,33 @@ Create a new ML model service connection to a platform such as Mlflow, Sklearn, - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. ```python POST /v1/services/mlmodelServices -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.generated.schema.api.services.createMlModelService import CreateMlModelServiceRequest -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) request = CreateMlModelServiceRequest( @@ -103,20 +112,27 @@ request = CreateMlModelServiceRequest( } ) -service = MlModelServices.create(request) -print(f"Created: {service.fullyQualifiedName}") +service = metadata.create_or_update(request) +print(f"Created: {service.fullyQualifiedName.root}") ``` ```java POST /v1/services/mlmodelServices -import static org.openmetadata.sdk.fluent.MlModelServices.*; - -MlModelService service = MlModelServices.builder() - .name("mlflow_svc") - .serviceType("Mlflow") - .connection(mlflowConnection() - .trackingUri("http://localhost:8088") - .registryUri("http://localhost:8088")) - .create(); +import org.openmetadata.schema.api.services.CreateMlModelService; +import org.openmetadata.schema.api.services.CreateMlModelService.MlModelServiceType; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.schema.services.connections.mlmodel.MlflowConnection; +import org.openmetadata.schema.type.MlModelConnection; +import org.openmetadata.sdk.fluent.MlModelServices; + +CreateMlModelService request = new CreateMlModelService() + .withName("mlflow_svc") + .withServiceType(MlModelServiceType.Mlflow) + .withConnection(new MlModelConnection().withConfig( + new MlflowConnection() + .withTrackingUri("http://localhost:8088") + .withRegistryUri("http://localhost:8088"))); + +MlModelService service = MlModelServices.create(request); ``` ```bash POST /v1/services/mlmodelServices @@ -196,7 +212,7 @@ Returns the created ML model service object with all specified properties and sy - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker, CustomMlModel). + Type of ML model service, for example Mlflow, Sklearn, SageMaker, CustomMlModel. @@ -218,7 +234,7 @@ Returns the created ML model service object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -227,7 +243,7 @@ Returns the created ML model service object with all specified properties and sy - + Fully qualified name of the assigned domain. @@ -240,11 +256,11 @@ Returns the created ML model service object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/delete.mdx index c2b42a870..43fcf5754 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/delete.mdx @@ -28,7 +28,7 @@ Delete an ML model service by ID or fully qualified name. Supports soft delete ( Use `DELETE /v1/services/mlmodelServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the ML model service (e.g., `mlflow_svc`). + Fully qualified name of the ML model service, for example `mlflow_svc`. @@ -49,39 +49,56 @@ Use `PUT /v1/services/mlmodelServices/restore` to restore a soft-deleted ML mode ```python DELETE /v1/services/mlmodelServices/{id} -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Soft delete by ID -MlModelServices.delete("ca22d46e-81b9-4e48-85b5-0adc44980da9") +metadata.delete(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") # Hard delete -MlModelServices.delete( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", +metadata.delete( + entity=MlModelService, + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", hard_delete=True ) # Delete by name -MlModelServices.delete_by_name("mlflow_svc") +service = metadata.get_by_name(entity=MlModelService, fqn="mlflow_svc") +metadata.delete(entity=MlModelService, entity_id=service.id) # Delete by name with options -MlModelServices.delete_by_name( - "mlflow_svc", +service = metadata.get_by_name(entity=MlModelService, fqn="mlflow_svc") +metadata.delete( + entity=MlModelService, + entity_id=service.id, hard_delete=True, recursive=True ) # Restore a soft-deleted ML model service -MlModelServices.restore("ca22d46e-81b9-4e48-85b5-0adc44980da9") +metadata.restore(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") ``` ```java DELETE /v1/services/mlmodelServices/{id} -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.fluent.MlModelServices; + +// client is an initialized OpenMetadataClient. // Soft delete MlModelServices.delete("ca22d46e-81b9-4e48-85b5-0adc44980da9").execute(); @@ -91,11 +108,12 @@ MlModelServices.delete("ca22d46e-81b9-4e48-85b5-0adc44980da9") .hardDelete() .execute(); -// Delete by name -MlModelServices.deleteByName("mlflow_svc").execute(); +// Delete by name (look up the ID first) +MlModelService service = MlModelServices.retrieveByName("mlflow_svc"); +MlModelServices.delete(service.getId()).execute(); -// Restore -MlModelServices.restore("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +// Restore. The fluent class has no restore method, so use the client service. +client.mlModelServices().restore("ca22d46e-81b9-4e48-85b5-0adc44980da9"); ``` ```bash DELETE /v1/services/mlmodelServices/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/list.mdx index cc2b9b248..35f6a9674 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/list.mdx @@ -33,56 +33,64 @@ List all ML model services with optional filtering and pagination. ```python GET /v1/services/mlmodelServices -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List first page -services = MlModelServices.list(limit=50) -for svc in services.data: - print(f"{svc.fullyQualifiedName} ({svc.serviceType})") +services = metadata.list_entities(entity=MlModelService, limit=50) +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root} ({svc.serviceType.value})") # List all with auto-pagination -for svc in MlModelServices.list_all(): - print(f"{svc.fullyQualifiedName}") +for svc in metadata.list_all_entities(entity=MlModelService): + print(f"{svc.fullyQualifiedName.root}") # List with fields -services = MlModelServices.list( +services = metadata.list_entities( + entity=MlModelService, fields=["owners", "tags", "domains"], limit=50 ) -for svc in services.data: - print(f"{svc.fullyQualifiedName}") +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root}") if svc.owners: - print(f" Owners: {[o.name for o in svc.owners]}") + print(f" Owners: {[o.name for o in svc.owners.root]}") ``` ```java GET /v1/services/mlmodelServices -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = MlModelServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.mlModelServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (MlModelService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } -// List with fields -var result = MlModelServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); -} +// With fields +ListResponse withFields = client.mlModelServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/mlmodelServices @@ -160,7 +168,7 @@ Returns a paginated list of ML model service objects. By default, only basic fie - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker, CustomMlModel). + Type of ML model service, for example Mlflow, Sklearn, SageMaker, CustomMlModel. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/retrieve.mdx index cf91cf7ee..1bcee370b 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single ML model service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single ML model service by its unique ID or fully qualified name. Use `GET /v1/services/mlmodelServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the ML model service (e.g., `mlflow_svc`). + Fully qualified name of the ML model service, for example `mlflow_svc`. @@ -41,51 +41,64 @@ Use `GET /v1/services/mlmodelServices/name/{fqn}` to retrieve by fully qualified ```python GET /v1/services/mlmodelServices/{id} -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Get by ID -svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9") -print(f"{svc.fullyQualifiedName}: {svc.serviceType}") +svc = metadata.get_by_id(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") +print(f"{svc.fullyQualifiedName.root}: {svc.serviceType.value}") # Get by ID with fields -svc = MlModelServices.retrieve( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", +svc = metadata.get_by_id( + entity=MlModelService, + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", fields=["owners", "tags"] ) # Get by fully qualified name -svc = MlModelServices.retrieve_by_name("mlflow_svc") +svc = metadata.get_by_name(entity=MlModelService, fqn="mlflow_svc") # Get by name with fields -svc = MlModelServices.retrieve_by_name( - "mlflow_svc", +svc = metadata.get_by_name( + entity=MlModelService, + fqn="mlflow_svc", fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/services/mlmodelServices/{id} -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.fluent.MlModelServices; // Get by ID -var svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +MlModelService service = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); // Get by ID with fields -var svc = MlModelServices.retrieve( +MlModelService serviceWithFields = MlModelServices.retrieve( "ca22d46e-81b9-4e48-85b5-0adc44980da9", "owners,tags" ); // Get by fully qualified name -var svc = MlModelServices.retrieveByName("mlflow_svc"); +MlModelService serviceByName = MlModelServices.retrieveByName("mlflow_svc"); // Get by name with fields -var svc = MlModelServices.retrieveByName("mlflow_svc", "owners,tags,domains"); +MlModelService serviceByNameWithFields = MlModelServices.retrieveByName("mlflow_svc", "owners,tags,domains"); ``` ```bash GET /v1/services/mlmodelServices/{id} @@ -163,7 +176,7 @@ Returns an ML model service object with all requested fields populated. - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker, CustomMlModel). + Type of ML model service, for example Mlflow, Sklearn, SageMaker, CustomMlModel. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/update.mdx index 9fa92a22e..f19c4f3d8 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/update.mdx @@ -20,7 +20,7 @@ Update an ML model service's properties using JSON Merge Patch. You can update b Use `PATCH /v1/services/mlmodelServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the ML model service (e.g., `mlflow_svc`). + Fully qualified name of the ML model service, for example `mlflow_svc`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,52 +68,58 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. ```python PATCH /v1/services/mlmodelServices/{id} -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Retrieve, modify, and update -svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9") -svc.description = "Updated: Production MLflow tracking server with model registry" -svc.connection = { - "config": { - "type": "Mlflow", - "trackingUri": "http://mlflow-prod:8088", - "registryUri": "http://mlflow-prod:8088", - "supportsMetadataExtraction": True - } -} -updated = MlModelServices.update(svc) - -print(f"Updated to version {updated.version}") +svc = metadata.get_by_id(entity=MlModelService, entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9") +modified = svc.model_copy(deep=True) +modified.description = "Updated: Production MLflow tracking server with model registry" +modified.connection.config.trackingUri = "http://mlflow-prod:8088" +modified.connection.config.registryUri = "http://mlflow-prod:8088" +updated = metadata.patch(entity=MlModelService, source=svc, destination=modified) + +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/services/mlmodelServices/{id} -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.sdk.fluent.MlModelServices; // Retrieve, modify, and update -var svc = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); -svc.setDescription("Updated: Production MLflow tracking server with model registry"); -var updated = MlModelServices.update(svc); +MlModelService service = MlModelServices.retrieve("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +service.setDescription("Updated: Production MLflow tracking server with model registry"); +MlModelService updated = MlModelServices.update(service); ``` ```bash PATCH /v1/services/mlmodelServices/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/versions.mdx index 7a37884e7..828c2be41 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodel-services/versions.mdx @@ -24,47 +24,62 @@ Use `GET /v1/services/mlmodelServices/{id}/versions/{version}` to retrieve a spe - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/services/mlmodelServices/{id}/versions -from metadata.sdk import configure -from metadata.sdk.entities import MlModelServices - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.services.mlmodelService import MlModelService + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List all versions -versions = MlModelServices.get_versions("ca22d46e-81b9-4e48-85b5-0adc44980da9") -for v in versions: - print(f"Version {v.version}: {v.description}") +history = metadata.list_versions( + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", + entity=MlModelService +) +for v in history.versions: + svc_version = MlModelService.model_validate_json(v) + print(f"Version {svc_version.version.root}: {getattr(svc_version.description, 'root', svc_version.description)}") # Get a specific version -svc_v1 = MlModelServices.get_specific_version( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", - "0.1" +svc_v1 = metadata.get_entity_version( + entity=MlModelService, + entity_id="ca22d46e-81b9-4e48-85b5-0adc44980da9", + version="0.1" ) -print(f"Original description: {svc_v1.description}") +print(f"Original description: {getattr(svc_v1.description, 'root', svc_v1.description)}") ``` ```java GET /v1/services/mlmodelServices/{id}/versions -import static org.openmetadata.sdk.fluent.MlModelServices.*; +import org.openmetadata.schema.entity.services.MlModelService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = MlModelServices.getVersions("ca22d46e-81b9-4e48-85b5-0adc44980da9"); +EntityHistory history = client.mlModelServices().getVersionList("ca22d46e-81b9-4e48-85b5-0adc44980da9"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = MlModelServices.getSpecificVersion( - "ca22d46e-81b9-4e48-85b5-0adc44980da9", - 0.1 -); +MlModelService v1 = client.mlModelServices().getVersion("ca22d46e-81b9-4e48-85b5-0adc44980da9", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/create.mdx index a637fadc9..d7a44ac80 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/create.mdx @@ -16,11 +16,11 @@ Create a new ML model within an ML model service. - Fully qualified name of the parent MlModelService (e.g., `mlflow_svc`). + Fully qualified name of the parent MlModelService, for example `mlflow_svc`. - Algorithm used by the ML model (e.g., `KMeans`, `RandomForest`, `XGBoost`, `Neural Network`). + Algorithm used by the ML model, for example `KMeans`, `RandomForest`, `XGBoost`, `Neural Network`. @@ -40,7 +40,7 @@ Create a new ML model within an ML model service. - Data type of the feature (e.g., `numerical`, `categorical`). + Data type of the feature, for example `numerical`, `categorical`. @@ -56,7 +56,7 @@ Create a new ML model within an ML model service. - Reference to the source entity (e.g., a table or column). + Reference to the source entity, for example a table or column. @@ -108,7 +108,7 @@ Create a new ML model within an ML model service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -117,8 +117,8 @@ Create a new ML model within an ML model service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -130,11 +130,11 @@ Create a new ML model within an ML model service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -178,20 +178,28 @@ request = CreateMlModelRequest( ) model = MLModels.create(request) -print(f"Created: {model.fullyQualifiedName}") +print(f"Created: {model.fullyQualifiedName.root}") ``` ```java POST /v1/mlmodels -import static org.openmetadata.sdk.fluent.MlModels.*; - -// Create using builder pattern -var model = MlModels.builder() - .name("customer_segmentation") - .displayName("Customer Segmentation Model") - .service("mlflow_svc") - .algorithm("KMeans") - .description("Segments customers into groups based on purchasing behavior") - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateMlModel; +import org.openmetadata.schema.entity.data.MlModel; +import org.openmetadata.schema.type.MlFeature; +import org.openmetadata.schema.type.MlFeatureDataType; +import org.openmetadata.sdk.fluent.MlModels; + +CreateMlModel request = new CreateMlModel() + .withName("customer_segmentation") + .withDisplayName("Customer Segmentation Model") + .withService("mlflow_svc") + .withAlgorithm("KMeans") + .withDescription("Segments customers into groups based on purchasing behavior") + .withMlFeatures(List.of( + new MlFeature().withName("total_spend").withDataType(MlFeatureDataType.Numerical), + new MlFeature().withName("purchase_frequency").withDataType(MlFeatureDataType.Numerical))); + +MlModel model = MlModels.create(request); ``` ```bash POST /v1/mlmodels @@ -363,7 +371,7 @@ Returns the created ML model object with all specified properties and system-gen - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker). + Type of ML model service, for example Mlflow, Sklearn, SageMaker. @@ -375,7 +383,7 @@ Returns the created ML model object with all specified properties and system-gen - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -397,11 +405,11 @@ Returns the created ML model object with all specified properties and system-gen - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/delete.mdx index 9acd600a0..93a26ebd3 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/delete.mdx @@ -28,7 +28,7 @@ Delete an ML model by ID or fully qualified name. Supports soft delete (default) Use `DELETE /v1/mlmodels/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the ML model (e.g., `mlflow_svc.customer_segmentation`). + Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`. @@ -67,11 +67,13 @@ MLModels.delete( ) # Delete by name -MLModels.delete_by_name("mlflow_svc.customer_segmentation") +model = MLModels.retrieve_by_name("mlflow_svc.customer_segmentation") +MLModels.delete(model.id) # Delete by name with options -MLModels.delete_by_name( - "mlflow_svc.customer_segmentation", +model = MLModels.retrieve_by_name("mlflow_svc.customer_segmentation") +MLModels.delete( + model.id, hard_delete=True ) @@ -80,21 +82,23 @@ MLModels.restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") ``` ```java DELETE /v1/mlmodels/{id} -import static org.openmetadata.sdk.fluent.MlModels.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.MlModel; + +// client is an initialized OpenMetadataClient. // Soft delete -MlModels.delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2").execute(); +client.mlModels().delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); // Hard delete -MlModels.delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") - .hardDelete() - .execute(); +client.mlModels().delete("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", Map.of("hardDelete", "true")); -// Delete by name -MlModels.deleteByName("mlflow_svc.customer_segmentation").execute(); +// Delete by name (look up the ID first) +MlModel model = client.mlModels().getByName("mlflow_svc.customer_segmentation"); +client.mlModels().delete(model.getId()); // Restore -MlModels.restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +client.mlModels().restore("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); ``` ```bash DELETE /v1/mlmodels/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/followers-votes.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/followers-votes.mdx index a1d991972..f81404a73 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/followers-votes.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/followers-votes.mdx @@ -51,47 +51,56 @@ Manage followers and votes for ML model entities. ```python PUT /v1/mlmodels/{id}/followers -from metadata.sdk import configure +from metadata.sdk import client, configure from metadata.sdk.entities import MLModels configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client model_id = "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2" user_id = "user-uuid-here" # Add a follower model = MLModels.add_followers(model_id, [user_id]) -print(f"Followers: {len(model.followers)}") +print(f"Followers: {len(model.followers.root)}") # Remove a follower model = MLModels.remove_followers(model_id, [user_id]) # Add a vote -model = MLModels.add_vote(model_id, vote_type="votedUp") +rest.put(f"/mlmodels/{model_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -model = MLModels.remove_vote(model_id) +rest.put(f"/mlmodels/{model_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/mlmodels/{id}/followers -import static org.openmetadata.sdk.fluent.MlModels.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String modelId = "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -MlModels.addFollower(modelId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/mlmodels/" + modelId + "/followers", userId); // Remove a follower -MlModels.removeFollower(modelId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/mlmodels/" + modelId + "/followers/" + userId, null); // Add a vote -MlModels.vote(modelId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/mlmodels/" + modelId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -MlModels.vote(modelId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/mlmodels/" + modelId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/mlmodels/{id}/followers diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/list.mdx index 8c39be9a6..989135a51 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/list.mdx @@ -47,49 +47,52 @@ configure( # List first page models = MLModels.list(limit=50) -for m in models.data: - print(f"{m.fullyQualifiedName} ({m.algorithm})") +for m in models.entities: + print(f"{m.fullyQualifiedName.root} ({m.algorithm})") # List all with auto-pagination for m in MLModels.list_all(): - print(f"{m.fullyQualifiedName}") + print(f"{m.fullyQualifiedName.root}") # Filter by service models = MLModels.list( - service="mlflow_svc", + filters={"service": "mlflow_svc"}, fields=["owners", "tags", "domains"], limit=50 ) -for m in models.data: - print(f"{m.fullyQualifiedName}") +for m in models.entities: + print(f"{m.fullyQualifiedName.root}") if m.owners: - print(f" Owners: {[o.name for o in m.owners]}") + print(f" Owners: {[o.name for o in m.owners.root]}") if m.tags: - print(f" Tags: {[t.tagFQN for t in m.tags]}") + print(f" Tags: {[tag.tagFQN.root for tag in m.tags]}") ``` ```java GET /v1/mlmodels -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = MlModels.list() - .limit(50) - .execute(); +ListResponse firstPage = client.mlModels().list(new ListParams().setLimit(50)); -for (var m : result.getData()) { - System.out.println(m.getFullyQualifiedName()); +for (MlModel item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = MlModels.list() - .service("mlflow_svc") - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var m : result.getData()) { - System.out.println(m.getFullyQualifiedName()); +ListResponse filtered = client.mlModels().list( + new ListParams() + .setService("mlflow_svc") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (MlModel item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -186,7 +189,7 @@ Returns a paginated list of ML model objects. By default, only basic fields are - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker). + Type of ML model service, for example Mlflow, Sklearn, SageMaker. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/retrieve.mdx index 6bf39484c..19f1c2222 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/retrieve.mdx @@ -16,7 +16,7 @@ Get a single ML model by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single ML model by its unique ID or fully qualified name. Use `GET /v1/mlmodels/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the ML model (e.g., `mlflow_svc.customer_segmentation`). + Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`. @@ -51,7 +51,7 @@ configure( # Get by ID model = MLModels.retrieve("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") -print(f"{model.fullyQualifiedName}: {model.algorithm}") +print(f"{model.fullyQualifiedName.root}: {model.algorithm}") # Get by ID with fields model = MLModels.retrieve( @@ -70,22 +70,24 @@ model = MLModels.retrieve_by_name( ``` ```java GET /v1/mlmodels/{id} -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; + +// client is an initialized OpenMetadataClient. // Get by ID -var model = MlModels.retrieve("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +MlModel model = client.mlModels().get("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); // Get by ID with fields -var model = MlModels.retrieve( +MlModel modelWithFields = client.mlModels().get( "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", "owners,tags,followers,votes" ); // Get by fully qualified name -var model = MlModels.retrieveByName("mlflow_svc.customer_segmentation"); +MlModel modelByName = client.mlModels().getByName("mlflow_svc.customer_segmentation"); // Get by name with fields -var model = MlModels.retrieveByName( +MlModel modelByNameWithFields = client.mlModels().getByName( "mlflow_svc.customer_segmentation", "owners,tags,domains" ); @@ -210,7 +212,7 @@ Returns an ML model object with all requested fields populated. - Type of ML model service (e.g., Mlflow, Sklearn, SageMaker). + Type of ML model service, for example Mlflow, Sklearn, SageMaker. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/update.mdx index 8e4a00e1a..0371a8256 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/update.mdx @@ -20,7 +20,7 @@ Update an ML model's properties using JSON Merge Patch. You can update by ID or Use `PATCH /v1/mlmodels/name/{fqn}` to update by fully qualified name. - Fully qualified name of the ML model (e.g., `mlflow_svc.customer_segmentation`). + Fully qualified name of the ML model, for example `mlflow_svc.customer_segmentation`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Data type of the feature (e.g., `numerical`, `categorical`). + Data type of the feature, for example `numerical`, `categorical`. @@ -80,7 +80,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -94,17 +94,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -130,16 +130,18 @@ model.mlHyperParameters = [ ] updated = MLModels.update(model) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/mlmodels/{id} -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var model = MlModels.retrieve("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +MlModel model = client.mlModels().get("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); model.setDescription("Updated: Customer segmentation using KMeans with 5 clusters"); -var updated = MlModels.update(model); +MlModel updated = client.mlModels().update(model.getId(), model); ``` ```bash PATCH /v1/mlmodels/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/versions.mdx index 51758b323..c97d78f78 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/mlmodels/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/mlmodels/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/mlmodels/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import MLModels @@ -40,7 +42,8 @@ configure( # List all versions versions = MLModels.get_versions("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version model_v1 = MLModels.get_specific_version( @@ -51,21 +54,21 @@ print(f"Original algorithm: {model_v1.algorithm}") ``` ```java GET /v1/mlmodels/{id}/versions -import static org.openmetadata.sdk.fluent.MlModels.*; +import org.openmetadata.schema.entity.data.MlModel; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = MlModels.getVersions("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); +EntityHistory history = client.mlModels().getVersionList("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = MlModels.getSpecificVersion( - "6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", - 0.1 -); -System.out.println("Algorithm: " + v1.getAlgorithm()); +MlModel v1 = client.mlModels().getVersion("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", 0.1); +System.out.println("Description: " + v1.getDescription()); ``` ```bash GET /v1/mlmodels/{id}/versions diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/create.mdx index eca9f3d69..34be0380b 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/create.mdx @@ -16,7 +16,7 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Type of pipeline service (e.g., `Airflow`, `GluePipeline`, `Airbyte`, `Dagster`, `Fivetran`, `DBTCloud`, `Nifi`, `DomoPipeline`, `CustomPipeline`, `Flink`, `KafkaConnect`, `SplineProducer`, `OpenLineage`). + Type of pipeline service, for example `Airflow`, `GluePipeline`, `Airbyte`, `Dagster`, `Fivetran`, `DBTCloud`, `Nifi`, `DomoPipeline`, `CustomPipeline`, `Flink`, `KafkaConnect`, `SplineProducer`, `OpenLineage`. @@ -24,7 +24,7 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Service-specific connection configuration (e.g., host, port, authentication for Airflow). + Service-specific connection configuration, for example host, port, authentication for Airflow. @@ -46,7 +46,7 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new pipeline service connection to a platform such as Airflow, Dagster, - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -113,14 +113,24 @@ print(f"Created: {service['fullyQualifiedName']}") ``` ```java POST /v1/services/pipelineServices -import static org.openmetadata.sdk.fluent.PipelineServices.*; - -PipelineService service = PipelineServices.builder() - .name("sample_airflow") - .serviceType("Airflow") - .connection(airflowConnection() - .hostPort("http://localhost:8080")) - .create(); +import java.net.URI; +import org.openmetadata.schema.api.services.CreatePipelineService; +import org.openmetadata.schema.api.services.CreatePipelineService.PipelineServiceType; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.schema.services.connections.pipeline.AirflowConnection; +import org.openmetadata.schema.services.connections.pipeline.BackendConnection; +import org.openmetadata.schema.type.PipelineConnection; +import org.openmetadata.sdk.fluent.PipelineServices; + +CreatePipelineService request = new CreatePipelineService() + .withName("sample_airflow") + .withServiceType(PipelineServiceType.Airflow) + .withConnection(new PipelineConnection().withConfig( + new AirflowConnection() + .withHostPort(URI.create("http://localhost:8080")) + .withConnection(new BackendConnection()))); + +PipelineService service = PipelineServices.create(request); ``` ```bash POST /v1/services/pipelineServices @@ -202,7 +212,7 @@ Returns the created pipeline service object with all specified properties and sy - Type of pipeline service (e.g., Airflow, Dagster, Fivetran). + Type of pipeline service, for example Airflow, Dagster, Fivetran. @@ -224,7 +234,7 @@ Returns the created pipeline service object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -233,7 +243,7 @@ Returns the created pipeline service object with all specified properties and sy - + Fully qualified name of the assigned domain. @@ -246,11 +256,11 @@ Returns the created pipeline service object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/delete.mdx index 1aca19934..1ab3ef4b0 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/delete.mdx @@ -28,7 +28,7 @@ Delete a pipeline service by ID or fully qualified name. Supports soft delete (d Use `DELETE /v1/services/pipelineServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. @@ -81,7 +81,10 @@ requests.put( ``` ```java DELETE /v1/services/pipelineServices/{id} -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.fluent.PipelineServices; + +// client is an initialized OpenMetadataClient. // Soft delete PipelineServices.delete("daa58a49-df05-48a3-a417-45dfd12eacf5").execute(); @@ -92,11 +95,12 @@ PipelineServices.delete("daa58a49-df05-48a3-a417-45dfd12eacf5") .recursive() .execute(); -// Delete by name -PipelineServices.deleteByName("sample_airflow").execute(); +// Delete by name (look up the ID first) +PipelineService service = PipelineServices.retrieveByName("sample_airflow"); +PipelineServices.delete(service.getId()).execute(); -// Restore -PipelineServices.restore("daa58a49-df05-48a3-a417-45dfd12eacf5"); +// Restore. The fluent class has no restore method, so use the client service. +client.pipelineServices().restore("daa58a49-df05-48a3-a417-45dfd12eacf5"); ``` ```bash DELETE /v1/services/pipelineServices/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/import-export.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/import-export.mdx index a1e545dda..86c70b4c1 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/import-export.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/import-export.mdx @@ -14,7 +14,7 @@ Export pipeline service metadata (pipelines, owners, tags) to CSV and import cha `GET /v1/services/pipelineServices/name/{fqn}/export` - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. ## Export Async @@ -79,38 +79,6 @@ response = requests.put( ) ``` -```java GET /v1/services/pipelineServices/name/{fqn}/export -import org.openmetadata.sdk.fluent.PipelineServices; - -// Synchronous export -String csvData = PipelineServices.exportCsv("sample_airflow") - .execute(); - -// Async export -String jobId = PipelineServices.exportCsv("sample_airflow") - .async() - .execute(); - -// Synchronous import (dry run) -String result = PipelineServices.importCsv("sample_airflow") - .withData(csvData) - .dryRun(true) - .execute(); - -// Apply import -String result = PipelineServices.importCsv("sample_airflow") - .withData(csvData) - .dryRun(false) - .execute(); - -// Async import -String jobId = PipelineServices.importCsv("sample_airflow") - .withData(csvData) - .dryRun(false) - .async() - .execute(); -``` - ```bash GET /v1/services/pipelineServices/name/{fqn}/export # Export to CSV curl "{base_url}/api/v1/services/pipelineServices/name/sample_airflow/export" \ diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/list.mdx index 3d20896a1..32ff85447 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/list.mdx @@ -55,22 +55,23 @@ response = requests.get( ``` ```java GET /v1/services/pipelineServices -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = PipelineServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.pipelineServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (PipelineService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } // With fields -var result = PipelineServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); +ListResponse withFields = client.pipelineServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/pipelineServices @@ -140,7 +141,7 @@ Returns a paginated list of pipeline service objects. By default, only basic fie - Type of pipeline service (e.g., Airflow, Dagster, Fivetran). + Type of pipeline service, for example Airflow, Dagster, Fivetran. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/retrieve.mdx index 69e8c852f..00405a859 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single pipeline service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single pipeline service by its unique ID or fully qualified name. Use `GET /v1/services/pipelineServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. @@ -74,22 +74,23 @@ response = requests.get( ``` ```java GET /v1/services/pipelineServices/{id} -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.fluent.PipelineServices; // Get by ID -var svc = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); +PipelineService service = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); // Get by ID with fields -var svc = PipelineServices.retrieve( +PipelineService serviceWithFields = PipelineServices.retrieve( "daa58a49-df05-48a3-a417-45dfd12eacf5", "owners,tags,domains" ); // Get by fully qualified name -var svc = PipelineServices.retrieveByName("sample_airflow"); +PipelineService serviceByName = PipelineServices.retrieveByName("sample_airflow"); // Get by name with fields -var svc = PipelineServices.retrieveByName("sample_airflow", "owners,tags,domains"); +PipelineService serviceByNameWithFields = PipelineServices.retrieveByName("sample_airflow", "owners,tags,domains"); ``` ```bash GET /v1/services/pipelineServices/{id} @@ -159,7 +160,7 @@ Returns a pipeline service object with all requested fields populated. - Type of pipeline service (e.g., Airflow, Dagster, Fivetran). + Type of pipeline service, for example Airflow, Dagster, Fivetran. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/update.mdx index e7440acf3..8a667bb88 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/update.mdx @@ -20,7 +20,7 @@ Update a pipeline service's properties using JSON Merge Patch. You can update by Use `PATCH /v1/services/pipelineServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the pipeline service (e.g., `sample_airflow`). + Fully qualified name of the pipeline service, for example `sample_airflow`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -104,12 +104,13 @@ print(f"Updated to version {updated['version']}") ``` ```java PATCH /v1/services/pipelineServices/{id} -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.sdk.fluent.PipelineServices; // Retrieve, modify, and update -var svc = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); -svc.setDescription("Updated Airflow production service"); -var updated = PipelineServices.update(svc); +PipelineService service = PipelineServices.retrieve("daa58a49-df05-48a3-a417-45dfd12eacf5"); +service.setDescription("Updated Airflow production service"); +PipelineService updated = PipelineServices.update(service); ``` ```bash PATCH /v1/services/pipelineServices/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/versions.mdx index 784d989f5..61dacd402 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipeline-services/versions.mdx @@ -24,7 +24,7 @@ Use `GET /v1/services/pipelineServices/{id}/versions/{version}` to retrieve a sp - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. @@ -51,20 +51,20 @@ response = requests.get( ``` ```java GET /v1/services/pipelineServices/{id}/versions -import static org.openmetadata.sdk.fluent.PipelineServices.*; +import org.openmetadata.schema.entity.services.PipelineService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = PipelineServices.getVersions("daa58a49-df05-48a3-a417-45dfd12eacf5"); +EntityHistory history = client.pipelineServices().getVersionList("daa58a49-df05-48a3-a417-45dfd12eacf5"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = PipelineServices.getSpecificVersion( - "daa58a49-df05-48a3-a417-45dfd12eacf5", - 0.1 -); +PipelineService v1 = client.pipelineServices().getVersion("daa58a49-df05-48a3-a417-45dfd12eacf5", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/create.mdx index d321f385a..72bf64500 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/create.mdx @@ -16,7 +16,7 @@ Create a new pipeline within a pipeline service. - Fully qualified name of the parent PipelineService (e.g., `sample_airflow`). + Fully qualified name of the parent PipelineService, for example `sample_airflow`. @@ -28,7 +28,7 @@ Create a new pipeline within a pipeline service. - URL to the pipeline definition in the source system (e.g., Airflow DAG URL). + URL to the pipeline definition in the source system, for example Airflow DAG URL. @@ -48,7 +48,7 @@ Create a new pipeline within a pipeline service. - Type of the task (e.g., `BatchTask`, `StreamTask`). + Type of the task, for example `BatchTask`, `StreamTask`. @@ -70,7 +70,7 @@ Create a new pipeline within a pipeline service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -79,8 +79,8 @@ Create a new pipeline within a pipeline service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -92,11 +92,11 @@ Create a new pipeline within a pipeline service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -144,19 +144,21 @@ request = CreatePipelineRequest( ) pipeline = Pipelines.create(request) -print(f"Created: {pipeline.fullyQualifiedName}") +print(f"Created: {pipeline.fullyQualifiedName.root}") ``` ```java POST /v1/pipelines -import static org.openmetadata.sdk.fluent.Pipelines.*; - -// Create using builder pattern -var pipeline = Pipelines.builder() - .name("dbt_analytics_customers") - .displayName("DBT Customer Analytics") - .service("sample_airflow") - .description("Analytics pipeline for customer data processing") - .create(); +import org.openmetadata.schema.api.data.CreatePipeline; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.sdk.fluent.Pipelines; + +CreatePipeline request = new CreatePipeline() + .withName("dbt_analytics_customers") + .withDisplayName("DBT Customer Analytics") + .withService("sample_airflow") + .withDescription("Analytics pipeline for customer data processing"); + +Pipeline pipeline = Pipelines.create(request); ``` ```bash POST /v1/pipelines @@ -300,7 +302,7 @@ Returns the created pipeline object with all specified properties and system-gen - Type of pipeline service (e.g., Airflow, Dagster, DBTCloud). + Type of pipeline service, for example Airflow, Dagster, DBTCloud. @@ -334,7 +336,7 @@ Returns the created pipeline object with all specified properties and system-gen - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -356,11 +358,11 @@ Returns the created pipeline object with all specified properties and system-gen - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/delete.mdx index 3c4ef637c..a5c660bff 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/delete.mdx @@ -28,7 +28,7 @@ Delete a pipeline by ID or fully qualified name. Supports soft delete (default), Use `DELETE /v1/pipelines/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the pipeline (e.g., `sample_airflow.dbt_analytics_customers`). + Fully qualified name of the pipeline, for example `sample_airflow.dbt_analytics_customers`. @@ -67,11 +67,13 @@ Pipelines.delete( ) # Delete by name -Pipelines.delete_by_name("sample_airflow.dbt_analytics_customers") +pipeline = Pipelines.retrieve_by_name("sample_airflow.dbt_analytics_customers") +Pipelines.delete(pipeline.id) # Delete by name with options -Pipelines.delete_by_name( - "sample_airflow.dbt_analytics_customers", +pipeline = Pipelines.retrieve_by_name("sample_airflow.dbt_analytics_customers") +Pipelines.delete( + pipeline.id, hard_delete=True ) @@ -80,22 +82,23 @@ Pipelines.restore("538faa63-d204-46ff-aead-d158d0401cac") ``` ```java DELETE /v1/pipelines/{id} -import static org.openmetadata.sdk.fluent.Pipelines.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.Pipeline; + +// client is an initialized OpenMetadataClient. // Soft delete -Pipelines.delete("538faa63-d204-46ff-aead-d158d0401cac").execute(); +client.pipelines().delete("538faa63-d204-46ff-aead-d158d0401cac"); // Hard delete -Pipelines.delete("538faa63-d204-46ff-aead-d158d0401cac") - .hardDelete() - .execute(); +client.pipelines().delete("538faa63-d204-46ff-aead-d158d0401cac", Map.of("hardDelete", "true")); -// Delete by name -Pipelines.deleteByName("sample_airflow.dbt_analytics_customers") - .execute(); +// Delete by name (look up the ID first) +Pipeline pipeline = client.pipelines().getByName("sample_airflow.dbt_analytics_customers"); +client.pipelines().delete(pipeline.getId()); // Restore -Pipelines.restore("538faa63-d204-46ff-aead-d158d0401cac"); +client.pipelines().restore("538faa63-d204-46ff-aead-d158d0401cac"); ``` ```bash DELETE /v1/pipelines/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/followers-votes.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/followers-votes.mdx index 91de606b7..111fe82f2 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/followers-votes.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/followers-votes.mdx @@ -51,47 +51,56 @@ Manage followers and votes for pipeline entities. ```python PUT /v1/pipelines/{id}/followers -from metadata.sdk import configure +from metadata.sdk import client, configure from metadata.sdk.entities import Pipelines configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client pipeline_id = "538faa63-d204-46ff-aead-d158d0401cac" user_id = "user-uuid-here" # Add a follower pipeline = Pipelines.add_followers(pipeline_id, [user_id]) -print(f"Followers: {len(pipeline.followers)}") +print(f"Followers: {len(pipeline.followers.root)}") # Remove a follower pipeline = Pipelines.remove_followers(pipeline_id, [user_id]) # Add a vote -pipeline = Pipelines.add_vote(pipeline_id, vote_type="votedUp") +rest.put(f"/pipelines/{pipeline_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -pipeline = Pipelines.remove_vote(pipeline_id) +rest.put(f"/pipelines/{pipeline_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/pipelines/{id}/followers -import static org.openmetadata.sdk.fluent.Pipelines.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String pipelineId = "538faa63-d204-46ff-aead-d158d0401cac"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -Pipelines.addFollower(pipelineId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/pipelines/" + pipelineId + "/followers", userId); // Remove a follower -Pipelines.removeFollower(pipelineId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/pipelines/" + pipelineId + "/followers/" + userId, null); // Add a vote -Pipelines.vote(pipelineId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/pipelines/" + pipelineId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -Pipelines.vote(pipelineId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/pipelines/" + pipelineId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/pipelines/{id}/followers diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/list.mdx index 173a1f872..a299d584d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/list.mdx @@ -47,49 +47,52 @@ configure( # List first page pipelines = Pipelines.list(limit=50) -for p in pipelines.data: - print(f"{p.fullyQualifiedName}") +for p in pipelines.entities: + print(f"{p.fullyQualifiedName.root}") # List all with auto-pagination for p in Pipelines.list_all(): - print(f"{p.fullyQualifiedName}") + print(f"{p.fullyQualifiedName.root}") # Filter by service pipelines = Pipelines.list( - service="sample_airflow", + filters={"service": "sample_airflow"}, fields=["owners", "tags", "tasks"], limit=50 ) -for p in pipelines.data: - print(f"{p.fullyQualifiedName}") +for p in pipelines.entities: + print(f"{p.fullyQualifiedName.root}") if p.owners: - print(f" Owners: {[o.name for o in p.owners]}") + print(f" Owners: {[o.name for o in p.owners.root]}") if p.tasks: - print(f" Tasks: {[t.name for t in p.tasks]}") + print(f" Tasks: {[task.name for task in p.tasks]}") ``` ```java GET /v1/pipelines -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = Pipelines.list() - .limit(50) - .execute(); +ListResponse firstPage = client.pipelines().list(new ListParams().setLimit(50)); -for (var p : result.getData()) { - System.out.println(p.getFullyQualifiedName()); +for (Pipeline item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = Pipelines.list() - .service("sample_airflow") - .fields("owners", "tags", "tasks") - .limit(50) - .execute(); - -for (var p : result.getData()) { - System.out.println(p.getFullyQualifiedName()); +ListResponse filtered = client.pipelines().list( + new ListParams() + .setService("sample_airflow") + .setFields("owners,tags,tasks") + .setLimit(50) +); + +for (Pipeline item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -181,7 +184,7 @@ Returns a paginated list of pipeline objects. By default, only basic fields are - Type of pipeline service (e.g., Airflow, Dagster, DBTCloud). + Type of pipeline service, for example Airflow, Dagster, DBTCloud. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/retrieve.mdx index 07a8956c3..15a7c5753 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/retrieve.mdx @@ -16,7 +16,7 @@ Get a single pipeline by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,tasks,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,tasks,sourceHash`. @@ -28,7 +28,7 @@ Get a single pipeline by its unique ID or fully qualified name. Use `GET /v1/pipelines/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the pipeline (e.g., `sample_airflow.dbt_analytics_customers`). + Fully qualified name of the pipeline, for example `sample_airflow.dbt_analytics_customers`. @@ -51,7 +51,7 @@ configure( # Get by ID pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac") -print(f"{pipeline.fullyQualifiedName}: {pipeline.description}") +print(f"{pipeline.fullyQualifiedName.root}: {getattr(pipeline.description, 'root', pipeline.description)}") # Get by ID with fields pipeline = Pipelines.retrieve( @@ -65,31 +65,31 @@ pipeline = Pipelines.retrieve_by_name("sample_airflow.dbt_analytics_customers") # Get by name with fields pipeline = Pipelines.retrieve_by_name( "sample_airflow.dbt_analytics_customers", - fields=["owners", "tags", "tasks", "domain"] + fields=["owners", "tags", "tasks", "domains"] ) ``` ```java GET /v1/pipelines/{id} -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; + +// client is an initialized OpenMetadataClient. // Get by ID -var pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac"); +Pipeline pipeline = client.pipelines().get("538faa63-d204-46ff-aead-d158d0401cac"); // Get by ID with fields -var pipeline = Pipelines.retrieve( +Pipeline pipelineWithFields = client.pipelines().get( "538faa63-d204-46ff-aead-d158d0401cac", "owners,tags,tasks" ); // Get by fully qualified name -var pipeline = Pipelines.retrieveByName( - "sample_airflow.dbt_analytics_customers" -); +Pipeline pipelineByName = client.pipelines().getByName("sample_airflow.dbt_analytics_customers"); // Get by name with fields -var pipeline = Pipelines.retrieveByName( +Pipeline pipelineByNameWithFields = client.pipelines().getByName( "sample_airflow.dbt_analytics_customers", - "owners,tags,tasks,domain" + "owners,tags,tasks,domains" ); ``` @@ -201,7 +201,7 @@ Returns a pipeline object with all requested fields populated. - Type of pipeline service (e.g., Airflow, Dagster, DBTCloud). + Type of pipeline service, for example Airflow, Dagster, DBTCloud. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/update.mdx index 7e63e4e60..d28464480 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/update.mdx @@ -20,7 +20,7 @@ Update a pipeline's properties using JSON Merge Patch. You can update by ID or b Use `PATCH /v1/pipelines/name/{fqn}` to update by fully qualified name. - Fully qualified name of the pipeline (e.g., `sample_airflow.dbt_analytics_customers`). + Fully qualified name of the pipeline, for example `sample_airflow.dbt_analytics_customers`. ## Body Parameters @@ -70,7 +70,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -84,17 +84,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -116,16 +116,18 @@ pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac") pipeline.description = "Updated: Analytics pipeline with incremental customer processing" updated = Pipelines.update(pipeline) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/pipelines/{id} -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var pipeline = Pipelines.retrieve("538faa63-d204-46ff-aead-d158d0401cac"); +Pipeline pipeline = client.pipelines().get("538faa63-d204-46ff-aead-d158d0401cac"); pipeline.setDescription("Updated: Analytics pipeline with incremental customer processing"); -var updated = Pipelines.update(pipeline); +Pipeline updated = client.pipelines().update(pipeline.getId(), pipeline); ``` ```bash PATCH /v1/pipelines/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/versions.mdx index 91884d0d7..23ccd44a5 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/pipelines/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/pipelines/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/pipelines/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Pipelines @@ -40,31 +42,32 @@ configure( # List all versions versions = Pipelines.get_versions("538faa63-d204-46ff-aead-d158d0401cac") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version pipeline_v1 = Pipelines.get_specific_version( "538faa63-d204-46ff-aead-d158d0401cac", "0.1" ) -print(f"Original description: {pipeline_v1.description}") +print(f"Original description: {getattr(pipeline_v1.description, 'root', pipeline_v1.description)}") ``` ```java GET /v1/pipelines/{id}/versions -import static org.openmetadata.sdk.fluent.Pipelines.*; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Pipelines.getVersions("538faa63-d204-46ff-aead-d158d0401cac"); +EntityHistory history = client.pipelines().getVersionList("538faa63-d204-46ff-aead-d158d0401cac"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Pipelines.getSpecificVersion( - "538faa63-d204-46ff-aead-d158d0401cac", - 0.1 -); +Pipeline v1 = client.pipelines().getVersion("538faa63-d204-46ff-aead-d158d0401cac", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/create.mdx index 94f1064f7..e5e11eeed 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/create.mdx @@ -16,7 +16,7 @@ Create a new search index within a search service. - Fully qualified name of the parent SearchService (e.g., `elasticsearch_sample`). + Fully qualified name of the parent SearchService, for example `elasticsearch_sample`. @@ -28,7 +28,7 @@ Create a new search index within a search service. - Data type of the field (e.g., `TEXT`, `KEYWORD`, `INT`, `OBJECT`). + Data type of the field, for example `TEXT`, `KEYWORD`, `INT`, `OBJECT`. @@ -58,7 +58,7 @@ Create a new search index within a search service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -67,8 +67,8 @@ Create a new search index within a search service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -80,11 +80,11 @@ Create a new search index within a search service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -116,19 +116,27 @@ request = CreateSearchIndexRequest( ) search_index = SearchIndexes.create(request) -print(f"Created: {search_index.fullyQualifiedName}") +print(f"Created: {search_index.fullyQualifiedName.root}") ``` ```java POST /v1/searchIndexes -import static org.openmetadata.sdk.fluent.SearchIndexes.*; - -// Create using builder pattern -var searchIndex = SearchIndexes.builder() - .name("table_search_index") - .displayName("TableSearchIndex") - .service("elasticsearch_sample") - .description("Search index for table entities") - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateSearchIndex; +import org.openmetadata.schema.entity.data.SearchIndex; +import org.openmetadata.schema.type.SearchIndexDataType; +import org.openmetadata.schema.type.SearchIndexField; +import org.openmetadata.sdk.fluent.SearchIndexes; + +CreateSearchIndex request = new CreateSearchIndex() + .withName("table_search_index") + .withDisplayName("TableSearchIndex") + .withService("elasticsearch_sample") + .withDescription("Search index for table entities") + .withFields(List.of( + new SearchIndexField().withName("name").withDataType(SearchIndexDataType.TEXT), + new SearchIndexField().withName("description").withDataType(SearchIndexDataType.TEXT))); + +SearchIndex searchIndex = SearchIndexes.create(request); ``` ```bash POST /v1/searchIndexes @@ -256,7 +264,7 @@ Returns the created search index object with all specified properties and system - Type of search service (e.g., ElasticSearch, OpenSearch). + Type of search service, for example ElasticSearch, OpenSearch. @@ -268,7 +276,7 @@ Returns the created search index object with all specified properties and system - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -290,11 +298,11 @@ Returns the created search index object with all specified properties and system - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/delete.mdx index fbfc5c0a8..7ecbf9f86 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/delete.mdx @@ -28,7 +28,7 @@ Delete a search index by ID or fully qualified name. Supports soft delete (defau Use `DELETE /v1/searchIndexes/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the search index (e.g., `elasticsearch_sample.table_search_index`). + Fully qualified name of the search index, for example `elasticsearch_sample.table_search_index`. @@ -67,11 +67,13 @@ SearchIndexes.delete( ) # Delete by name -SearchIndexes.delete_by_name("elasticsearch_sample.table_search_index") +index = SearchIndexes.retrieve_by_name("elasticsearch_sample.table_search_index") +SearchIndexes.delete(index.id) # Delete by name with options -SearchIndexes.delete_by_name( - "elasticsearch_sample.table_search_index", +index = SearchIndexes.retrieve_by_name("elasticsearch_sample.table_search_index") +SearchIndexes.delete( + index.id, hard_delete=True ) @@ -80,22 +82,23 @@ SearchIndexes.restore("f5b0fa81-f241-4508-9219-dae31dcced18") ``` ```java DELETE /v1/searchIndexes/{id} -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.SearchIndex; + +// client is an initialized OpenMetadataClient. // Soft delete -SearchIndexes.delete("f5b0fa81-f241-4508-9219-dae31dcced18").execute(); +client.searchIndexes().delete("f5b0fa81-f241-4508-9219-dae31dcced18"); // Hard delete -SearchIndexes.delete("f5b0fa81-f241-4508-9219-dae31dcced18") - .hardDelete() - .execute(); +client.searchIndexes().delete("f5b0fa81-f241-4508-9219-dae31dcced18", Map.of("hardDelete", "true")); -// Delete by name -SearchIndexes.deleteByName("elasticsearch_sample.table_search_index") - .execute(); +// Delete by name (look up the ID first) +SearchIndex searchIndex = client.searchIndexes().getByName("elasticsearch_sample.table_search_index"); +client.searchIndexes().delete(searchIndex.getId()); // Restore -SearchIndexes.restore("f5b0fa81-f241-4508-9219-dae31dcced18"); +client.searchIndexes().restore("f5b0fa81-f241-4508-9219-dae31dcced18"); ``` ```bash DELETE /v1/searchIndexes/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/followers-votes.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/followers-votes.mdx index ecddf695b..155fe12de 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/followers-votes.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/followers-votes.mdx @@ -51,47 +51,56 @@ Manage followers and votes for search index entities. ```python PUT /v1/searchIndexes/{id}/followers -from metadata.sdk import configure +from metadata.sdk import client, configure from metadata.sdk.entities import SearchIndexes configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client si_id = "f5b0fa81-f241-4508-9219-dae31dcced18" user_id = "user-uuid-here" # Add a follower si = SearchIndexes.add_followers(si_id, [user_id]) -print(f"Followers: {len(si.followers)}") +print(f"Followers: {len(si.followers.root)}") # Remove a follower si = SearchIndexes.remove_followers(si_id, [user_id]) # Add a vote -si = SearchIndexes.add_vote(si_id, vote_type="votedUp") +rest.put(f"/searchIndexes/{si_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -si = SearchIndexes.remove_vote(si_id) +rest.put(f"/searchIndexes/{si_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/searchIndexes/{id}/followers -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String siId = "f5b0fa81-f241-4508-9219-dae31dcced18"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -SearchIndexes.addFollower(siId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/searchIndexes/" + siId + "/followers", userId); // Remove a follower -SearchIndexes.removeFollower(siId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/searchIndexes/" + siId + "/followers/" + userId, null); // Add a vote -SearchIndexes.vote(siId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/searchIndexes/" + siId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -SearchIndexes.vote(siId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/searchIndexes/" + siId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/searchIndexes/{id}/followers diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/list.mdx index 091a72ac4..7da009e21 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/list.mdx @@ -47,49 +47,52 @@ configure( # List first page indexes = SearchIndexes.list(limit=50) -for si in indexes.data: - print(f"{si.fullyQualifiedName}") +for si in indexes.entities: + print(f"{si.fullyQualifiedName.root}") # List all with auto-pagination for si in SearchIndexes.list_all(): - print(f"{si.fullyQualifiedName}") + print(f"{si.fullyQualifiedName.root}") # Filter by service indexes = SearchIndexes.list( - service="elasticsearch_sample", - fields=["owners", "tags", "domain"], + filters={"service": "elasticsearch_sample"}, + fields=["owners", "tags", "domains"], limit=50 ) -for si in indexes.data: - print(f"{si.fullyQualifiedName}") +for si in indexes.entities: + print(f"{si.fullyQualifiedName.root}") if si.owners: - print(f" Owners: {[o.name for o in si.owners]}") + print(f" Owners: {[o.name for o in si.owners.root]}") if si.tags: - print(f" Tags: {[t.tagFQN for t in si.tags]}") + print(f" Tags: {[tag.tagFQN.root for tag in si.tags]}") ``` ```java GET /v1/searchIndexes -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = SearchIndexes.list() - .limit(50) - .execute(); +ListResponse firstPage = client.searchIndexes().list(new ListParams().setLimit(50)); -for (var si : result.getData()) { - System.out.println(si.getFullyQualifiedName()); +for (SearchIndex item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = SearchIndexes.list() - .service("elasticsearch_sample") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var si : result.getData()) { - System.out.println(si.getFullyQualifiedName()); +ListResponse filtered = client.searchIndexes().list( + new ListParams() + .setService("elasticsearch_sample") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (SearchIndex item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -179,7 +182,7 @@ Returns a paginated list of search index objects. By default, only basic fields - Type of search service (e.g., ElasticSearch, OpenSearch). + Type of search service, for example ElasticSearch, OpenSearch. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/retrieve.mdx index 3e9115922..21218be93 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/retrieve.mdx @@ -16,7 +16,7 @@ Get a single search index by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single search index by its unique ID or fully qualified name. Use `GET /v1/searchIndexes/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the search index (e.g., `elasticsearch_sample.table_search_index`). + Fully qualified name of the search index, for example `elasticsearch_sample.table_search_index`. @@ -51,7 +51,7 @@ configure( # Get by ID si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18") -print(f"{si.fullyQualifiedName}: {si.description}") +print(f"{si.fullyQualifiedName.root}: {getattr(si.description, 'root', si.description)}") # Get by ID with fields si = SearchIndexes.retrieve( @@ -65,31 +65,31 @@ si = SearchIndexes.retrieve_by_name("elasticsearch_sample.table_search_index") # Get by name with fields si = SearchIndexes.retrieve_by_name( "elasticsearch_sample.table_search_index", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/searchIndexes/{id} -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; + +// client is an initialized OpenMetadataClient. // Get by ID -var si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18"); +SearchIndex searchIndex = client.searchIndexes().get("f5b0fa81-f241-4508-9219-dae31dcced18"); // Get by ID with fields -var si = SearchIndexes.retrieve( +SearchIndex searchIndexWithFields = client.searchIndexes().get( "f5b0fa81-f241-4508-9219-dae31dcced18", "owners,tags,fields" ); // Get by fully qualified name -var si = SearchIndexes.retrieveByName( - "elasticsearch_sample.table_search_index" -); +SearchIndex searchIndexByName = client.searchIndexes().getByName("elasticsearch_sample.table_search_index"); // Get by name with fields -var si = SearchIndexes.retrieveByName( +SearchIndex searchIndexByNameWithFields = client.searchIndexes().getByName( "elasticsearch_sample.table_search_index", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -220,7 +220,7 @@ Returns a search index object with all requested fields populated. - Type of search service (e.g., ElasticSearch, OpenSearch). + Type of search service, for example ElasticSearch, OpenSearch. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/update.mdx index 14626c8fb..cc837b01f 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/update.mdx @@ -20,7 +20,7 @@ Update a search index's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/searchIndexes/name/{fqn}` to update by fully qualified name. - Fully qualified name of the search index (e.g., `elasticsearch_sample.table_search_index`). + Fully qualified name of the search index, for example `elasticsearch_sample.table_search_index`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,17 +58,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -90,16 +90,18 @@ si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18") si.description = "Updated: Search index for table entities with enhanced mapping" updated = SearchIndexes.update(si) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/searchIndexes/{id} -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var si = SearchIndexes.retrieve("f5b0fa81-f241-4508-9219-dae31dcced18"); -si.setDescription("Updated: Search index for table entities with enhanced mapping"); -var updated = SearchIndexes.update(si); +SearchIndex searchIndex = client.searchIndexes().get("f5b0fa81-f241-4508-9219-dae31dcced18"); +searchIndex.setDescription("Updated: Search index for table entities with enhanced mapping"); +SearchIndex updated = client.searchIndexes().update(searchIndex.getId(), searchIndex); ``` ```bash PATCH /v1/searchIndexes/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/versions.mdx index 9e36a2bcc..f62acaace 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/search-indexes/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/searchIndexes/{id}/versions/{version}` to retrieve a specific versi - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/searchIndexes/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import SearchIndexes @@ -40,31 +42,32 @@ configure( # List all versions versions = SearchIndexes.get_versions("f5b0fa81-f241-4508-9219-dae31dcced18") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version si_v1 = SearchIndexes.get_specific_version( "f5b0fa81-f241-4508-9219-dae31dcced18", "0.1" ) -print(f"Original description: {si_v1.description}") +print(f"Original description: {getattr(si_v1.description, 'root', si_v1.description)}") ``` ```java GET /v1/searchIndexes/{id}/versions -import static org.openmetadata.sdk.fluent.SearchIndexes.*; +import org.openmetadata.schema.entity.data.SearchIndex; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = SearchIndexes.getVersions("f5b0fa81-f241-4508-9219-dae31dcced18"); +EntityHistory history = client.searchIndexes().getVersionList("f5b0fa81-f241-4508-9219-dae31dcced18"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = SearchIndexes.getSpecificVersion( - "f5b0fa81-f241-4508-9219-dae31dcced18", - 0.1 -); +SearchIndex v1 = client.searchIndexes().getVersion("f5b0fa81-f241-4508-9219-dae31dcced18", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/create.mdx index 54fcd1fb8..5ae74b3fd 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/create.mdx @@ -16,7 +16,7 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Type of storage service (e.g., `S3`, `GCS`, `ADLS`, `CustomStorage`). + Type of storage service, for example `S3`, `GCS`, `ADLS`, `CustomStorage`. @@ -24,7 +24,7 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Service-specific connection configuration (e.g., AWS credentials for S3, project ID for GCS). + Service-specific connection configuration, for example AWS credentials for S3, project ID for GCS. @@ -46,7 +46,7 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -55,8 +55,8 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -68,11 +68,11 @@ Create a new storage service connection to a platform such as S3, GCS, or ADLS. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -107,20 +107,29 @@ request = CreateStorageServiceRequest( ) service = StorageServices.create(request) -print(f"Created: {service.fullyQualifiedName}") +print(f"Created: {service.fullyQualifiedName.root}") ``` ```java POST /v1/services/storageServices -import static org.openmetadata.sdk.fluent.StorageServices.*; - -StorageService service = StorageServices.builder() - .name("s3_datalake") - .serviceType("S3") - .connection(s3Connection() - .awsAccessKeyId("AKIA...") - .awsSecretAccessKey("***") - .awsRegion("us-east-1")) - .create(); +import org.openmetadata.schema.api.services.CreateStorageService; +import org.openmetadata.schema.api.services.CreateStorageService.StorageServiceType; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.schema.security.credentials.AWSCredentials; +import org.openmetadata.schema.services.connections.storage.S3Connection; +import org.openmetadata.schema.type.StorageConnection; +import org.openmetadata.sdk.fluent.StorageServices; + +CreateStorageService request = new CreateStorageService() + .withName("s3_datalake") + .withServiceType(StorageServiceType.S3) + .withConnection(new StorageConnection().withConfig( + new S3Connection().withAwsConfig( + new AWSCredentials() + .withAwsAccessKeyId("AKIA...") + .withAwsSecretAccessKey("***") + .withAwsRegion("us-east-1")))); + +StorageService service = StorageServices.create(request); ``` ```bash POST /v1/services/storageServices @@ -207,7 +216,7 @@ Returns the created storage service object with all specified properties and sys - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. @@ -229,7 +238,7 @@ Returns the created storage service object with all specified properties and sys - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -238,7 +247,7 @@ Returns the created storage service object with all specified properties and sys - + Fully qualified name of the assigned domain. @@ -251,11 +260,11 @@ Returns the created storage service object with all specified properties and sys - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/delete.mdx index a0d07c59b..89cab6fac 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/delete.mdx @@ -28,7 +28,7 @@ Delete a storage service by ID or fully qualified name. Supports soft delete (de Use `DELETE /v1/services/storageServices/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the storage service (e.g., `s3_datalake`). + Fully qualified name of the storage service, for example `s3_datalake`. @@ -67,11 +67,11 @@ StorageServices.delete( ) # Delete by name -StorageServices.delete_by_name("s3_datalake") +StorageServices.delete(StorageServices.retrieve_by_name("s3_datalake").id) # Delete by name with options -StorageServices.delete_by_name( - "s3_datalake", +StorageServices.delete( + StorageServices.retrieve_by_name("s3_datalake").id, hard_delete=True, recursive=True ) @@ -81,7 +81,10 @@ StorageServices.restore("d1589e1d-2ab0-431c-a383-15e4be20a106") ``` ```java DELETE /v1/services/storageServices/{id} -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.fluent.StorageServices; + +// client is an initialized OpenMetadataClient. // Soft delete StorageServices.delete("d1589e1d-2ab0-431c-a383-15e4be20a106").execute(); @@ -91,11 +94,12 @@ StorageServices.delete("d1589e1d-2ab0-431c-a383-15e4be20a106") .hardDelete() .execute(); -// Delete by name -StorageServices.deleteByName("s3_datalake").execute(); +// Delete by name (look up the ID first) +StorageService service = StorageServices.retrieveByName("s3_datalake"); +StorageServices.delete(service.getId()).execute(); -// Restore -StorageServices.restore("d1589e1d-2ab0-431c-a383-15e4be20a106"); +// Restore. The fluent class has no restore method, so use the client service. +client.storageServices().restore("d1589e1d-2ab0-431c-a383-15e4be20a106"); ``` ```bash DELETE /v1/services/storageServices/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/list.mdx index 2d7378506..9a296fed8 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/list.mdx @@ -43,12 +43,12 @@ configure( # List first page services = StorageServices.list(limit=50) -for svc in services.data: - print(f"{svc.fullyQualifiedName} ({svc.serviceType})") +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root} ({svc.serviceType})") # List all with auto-pagination for svc in StorageServices.list_all(): - print(f"{svc.fullyQualifiedName}") + print(f"{svc.fullyQualifiedName.root}") # List with fields services = StorageServices.list( @@ -56,33 +56,30 @@ services = StorageServices.list( limit=50 ) -for svc in services.data: - print(f"{svc.fullyQualifiedName}") +for svc in services.entities: + print(f"{svc.fullyQualifiedName.root}") if svc.owners: - print(f" Owners: {[o.name for o in svc.owners]}") + print(f" Owners: {[o.name for o in svc.owners.root]}") ``` ```java GET /v1/services/storageServices -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = StorageServices.list() - .limit(50) - .execute(); +ListResponse firstPage = client.storageServices().list(new ListParams().setLimit(50)); -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); +for (StorageService service : firstPage.getData()) { + System.out.println(service.getFullyQualifiedName()); } -// List with fields -var result = StorageServices.list() - .fields("owners", "tags", "domains") - .limit(50) - .execute(); - -for (var svc : result.getData()) { - System.out.println(svc.getFullyQualifiedName()); -} +// With fields +ListResponse withFields = client.storageServices().list( + new ListParams().setFields("owners,tags,domains").setLimit(50) +); ``` ```bash GET /v1/services/storageServices @@ -165,7 +162,7 @@ Returns a paginated list of storage service objects. By default, only basic fiel - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/retrieve.mdx index 7ee640325..56392dc50 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/retrieve.mdx @@ -16,7 +16,7 @@ Get a single storage service by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains`). + Comma-separated list of fields to include, for example `owners,tags,domains`. @@ -28,7 +28,7 @@ Get a single storage service by its unique ID or fully qualified name. Use `GET /v1/services/storageServices/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the storage service (e.g., `s3_datalake`). + Fully qualified name of the storage service, for example `s3_datalake`. @@ -51,7 +51,7 @@ configure( # Get by ID svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106") -print(f"{svc.fullyQualifiedName}: {svc.serviceType}") +print(f"{svc.fullyQualifiedName.root}: {svc.serviceType}") # Get by ID with fields svc = StorageServices.retrieve( @@ -70,22 +70,23 @@ svc = StorageServices.retrieve_by_name( ``` ```java GET /v1/services/storageServices/{id} -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.fluent.StorageServices; // Get by ID -var svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); +StorageService service = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); // Get by ID with fields -var svc = StorageServices.retrieve( +StorageService serviceWithFields = StorageServices.retrieve( "d1589e1d-2ab0-431c-a383-15e4be20a106", "owners,tags" ); // Get by fully qualified name -var svc = StorageServices.retrieveByName("s3_datalake"); +StorageService serviceByName = StorageServices.retrieveByName("s3_datalake"); // Get by name with fields -var svc = StorageServices.retrieveByName("s3_datalake", "owners,tags,domains"); +StorageService serviceByNameWithFields = StorageServices.retrieveByName("s3_datalake", "owners,tags,domains"); ``` ```bash GET /v1/services/storageServices/{id} @@ -168,7 +169,7 @@ Returns a storage service object with all requested fields populated. - Type of storage service (e.g., S3, GCS, ADLS, CustomStorage). + Type of storage service, for example S3, GCS, ADLS, CustomStorage. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/update.mdx index 8c583953e..d724d7f54 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/update.mdx @@ -20,7 +20,7 @@ Update a storage service's properties using JSON Merge Patch. You can update by Use `PATCH /v1/services/storageServices/name/{fqn}` to update by fully qualified name. - Fully qualified name of the storage service (e.g., `s3_datalake`). + Fully qualified name of the storage service, for example `s3_datalake`. ## Body Parameters @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -96,16 +96,17 @@ svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106") svc.description = "Updated: Production S3 data lake with new region configuration" updated = StorageServices.update(svc) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/services/storageServices/{id} -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.sdk.fluent.StorageServices; // Retrieve, modify, and update -var svc = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); -svc.setDescription("Updated: Production S3 data lake with new region configuration"); -var updated = StorageServices.update(svc); +StorageService service = StorageServices.retrieve("d1589e1d-2ab0-431c-a383-15e4be20a106"); +service.setDescription("Updated: Production S3 data lake with new region configuration"); +StorageService updated = StorageServices.update(service); ``` ```bash PATCH /v1/services/storageServices/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/versions.mdx index 9863d95dd..acca64ece 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/storage-services/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/services/storageServices/{id}/versions/{version}` to retrieve a spe - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/services/storageServices/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import StorageServices @@ -40,31 +42,32 @@ configure( # List all versions versions = StorageServices.get_versions("d1589e1d-2ab0-431c-a383-15e4be20a106") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version svc_v1 = StorageServices.get_specific_version( "d1589e1d-2ab0-431c-a383-15e4be20a106", "0.1" ) -print(f"Original description: {svc_v1.description}") +print(f"Original description: {getattr(svc_v1.description, 'root', svc_v1.description)}") ``` ```java GET /v1/services/storageServices/{id}/versions -import static org.openmetadata.sdk.fluent.StorageServices.*; +import org.openmetadata.schema.entity.services.StorageService; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = StorageServices.getVersions("d1589e1d-2ab0-431c-a383-15e4be20a106"); +EntityHistory history = client.storageServices().getVersionList("d1589e1d-2ab0-431c-a383-15e4be20a106"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = StorageServices.getSpecificVersion( - "d1589e1d-2ab0-431c-a383-15e4be20a106", - 0.1 -); +StorageService v1 = client.storageServices().getVersion("d1589e1d-2ab0-431c-a383-15e4be20a106", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/create.mdx index 9823729c4..bd0477ff2 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/create.mdx @@ -16,7 +16,7 @@ Create a new stored procedure within a database schema. - Fully qualified name of the parent DatabaseSchema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the parent DatabaseSchema, for example `snowflake_prod.analytics.public`. @@ -28,7 +28,7 @@ Create a new stored procedure within a database schema. - Programming language of the code (e.g., `SQL`, `JavaScript`, `Python`). + Programming language of the code, for example `SQL`, `JavaScript`, `Python`. @@ -50,7 +50,7 @@ Create a new stored procedure within a database schema. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -59,8 +59,8 @@ Create a new stored procedure within a database schema. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -72,11 +72,11 @@ Create a new stored procedure within a database schema. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -108,19 +108,27 @@ request = CreateStoredProcedureRequest( ) stored_procedure = StoredProcedures.create(request) -print(f"Created: {stored_procedure.fullyQualifiedName}") +print(f"Created: {stored_procedure.fullyQualifiedName.root}") ``` ```java POST /v1/storedProcedures -import static org.openmetadata.sdk.fluent.StoredProcedures.*; - -// Create using builder pattern -var storedProcedure = StoredProcedures.builder() - .name("usp_refresh_analytics") - .displayName("Refresh Analytics") - .databaseSchema("snowflake_prod.analytics.public") - .description("Refreshes materialized analytics views nightly") - .create(); +import org.openmetadata.schema.api.data.CreateStoredProcedure; +import org.openmetadata.schema.entity.data.StoredProcedure; +import org.openmetadata.schema.api.data.StoredProcedureCode; +import org.openmetadata.schema.type.StoredProcedureLanguage; + +// client is an initialized OpenMetadataClient. + +CreateStoredProcedure request = new CreateStoredProcedure() + .withName("usp_refresh_analytics") + .withDisplayName("Refresh Analytics") + .withDatabaseSchema("snowflake_prod.analytics.public") + .withDescription("Refreshes materialized analytics views nightly") + .withStoredProcedureCode(new StoredProcedureCode() + .withCode("CREATE OR REPLACE PROCEDURE usp_refresh_analytics() ...") + .withLanguage(StoredProcedureLanguage.SQL)); + +StoredProcedure storedProcedure = client.storedProcedures().create(request); ``` ```bash POST /v1/storedProcedures @@ -249,7 +257,7 @@ Returns the created stored procedure object with all specified properties and sy - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. @@ -261,7 +269,7 @@ Returns the created stored procedure object with all specified properties and sy - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -283,11 +291,11 @@ Returns the created stored procedure object with all specified properties and sy - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/delete.mdx index 2826b70d1..e2bcf6ae7 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/delete.mdx @@ -28,7 +28,7 @@ Delete a stored procedure by ID or fully qualified name. Supports soft delete (d Use `DELETE /v1/storedProcedures/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the stored procedure (e.g., `snowflake_prod.analytics.public.usp_refresh_analytics`). + Fully qualified name of the stored procedure, for example `snowflake_prod.analytics.public.usp_refresh_analytics`. @@ -66,36 +66,40 @@ StoredProcedures.delete( hard_delete=True ) -# Delete by name -StoredProcedures.delete_by_name("snowflake_prod.analytics.public.usp_refresh_analytics") +# Delete by name (look up the ID first) +entity = StoredProcedures.retrieve_by_name("snowflake_prod.analytics.public.usp_refresh_analytics") +StoredProcedures.delete(entity.id) # Delete by name with options -StoredProcedures.delete_by_name( - "snowflake_prod.analytics.public.usp_refresh_analytics", - hard_delete=True -) +entity = StoredProcedures.retrieve_by_name("snowflake_prod.analytics.public.usp_refresh_analytics") +StoredProcedures.delete(entity.id, hard_delete=True) # Restore a soft-deleted stored procedure StoredProcedures.restore("770e8400-e29b-41d4-a716-446655440000") ``` ```java DELETE /v1/storedProcedures/{id} -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import java.util.Map; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. // Soft delete -StoredProcedures.delete("770e8400-e29b-41d4-a716-446655440000").execute(); +client.storedProcedures().delete("770e8400-e29b-41d4-a716-446655440000"); // Hard delete -StoredProcedures.delete("770e8400-e29b-41d4-a716-446655440000") - .hardDelete() - .execute(); +client.storedProcedures().delete("770e8400-e29b-41d4-a716-446655440000", Map.of("hardDelete", "true")); // Delete by name -StoredProcedures.deleteByName("snowflake_prod.analytics.public.usp_refresh_analytics") - .execute(); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/storedProcedures/name/snowflake_prod.analytics.public.usp_refresh_analytics", + null, + Void.class +); // Restore -StoredProcedures.restore("770e8400-e29b-41d4-a716-446655440000"); +client.storedProcedures().restore("770e8400-e29b-41d4-a716-446655440000"); ``` ```bash DELETE /v1/storedProcedures/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/followers-votes.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/followers-votes.mdx index 172f5849f..4376c0aad 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/followers-votes.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/followers-votes.mdx @@ -51,7 +51,7 @@ Manage followers and votes for stored procedure entities. ```python PUT /v1/storedProcedures/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import StoredProcedures configure( @@ -59,39 +59,62 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + sp_id = "770e8400-e29b-41d4-a716-446655440000" user_id = "user-uuid-here" # Add a follower sp = StoredProcedures.add_followers(sp_id, [user_id]) -print(f"Followers: {len(sp.followers)}") +print(f"Followers: {len(sp.followers.root)}") # Remove a follower sp = StoredProcedures.remove_followers(sp_id, [user_id]) # Add a vote -sp = StoredProcedures.add_vote(sp_id, vote_type="votedUp") +rest.put(f"/storedProcedures/{sp_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -sp = StoredProcedures.remove_vote(sp_id) +rest.put(f"/storedProcedures/{sp_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/storedProcedures/{id}/followers -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String spId = "770e8400-e29b-41d4-a716-446655440000"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; // Add a follower -StoredProcedures.addFollower(spId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/storedProcedures/" + spId + "/followers", + UUID.fromString(userId) +); // Remove a follower -StoredProcedures.removeFollower(spId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/storedProcedures/" + spId + "/followers/" + userId, + null +); // Add a vote -StoredProcedures.vote(spId, "votedUp"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/storedProcedures/" + spId + "/vote", + Map.of("updatedVoteType", "votedUp") +); // Remove a vote -StoredProcedures.vote(spId, "unVoted"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/storedProcedures/" + spId + "/vote", + Map.of("updatedVoteType", "unVoted") +); ``` ```bash PUT /v1/storedProcedures/{id}/followers diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/list.mdx index 6ddfef431..60af92a49 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/list.mdx @@ -51,48 +51,53 @@ configure( # List first page procedures = StoredProcedures.list(limit=50) -for sp in procedures.data: - print(f"{sp.fullyQualifiedName}") +for sp in procedures.entities: + print(f"{sp.fullyQualifiedName.root}") # List all with auto-pagination for sp in StoredProcedures.list_all(): - print(f"{sp.fullyQualifiedName}") + print(f"{sp.fullyQualifiedName.root}") # Filter by database schema procedures = StoredProcedures.list( - databaseSchema="snowflake_prod.analytics.public", - fields=["owners", "tags", "domain"], + filters={"databaseSchema": "snowflake_prod.analytics.public"}, + fields=["owners", "tags", "domains"], limit=50 ) -for sp in procedures.data: - print(f"{sp.fullyQualifiedName}") +for sp in procedures.entities: + print(f"{sp.fullyQualifiedName.root}") if sp.owners: - print(f" Owners: {[o.name for o in sp.owners]}") + print(f" Owners: {[o.name for o in sp.owners.root]}") if sp.tags: - print(f" Tags: {[t.tagFQN for t in sp.tags]}") + print(f" Tags: {[t.tagFQN.root for t in sp.tags]}") ``` ```java GET /v1/storedProcedures -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; +import org.openmetadata.schema.entity.data.StoredProcedure; + +// client is an initialized OpenMetadataClient. // List first page -var result = StoredProcedures.list() - .limit(50) - .execute(); +ListResponse firstPage = client.storedProcedures().list( + new ListParams().setLimit(50) +); -for (var sp : result.getData()) { +for (StoredProcedure sp : firstPage.getData()) { System.out.println(sp.getFullyQualifiedName()); } // Filter by database schema with fields -var result = StoredProcedures.list() - .databaseSchema("snowflake_prod.analytics.public") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var sp : result.getData()) { +ListResponse filtered = client.storedProcedures().list( + new ListParams() + .setDatabaseSchema("snowflake_prod.analytics.public") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (StoredProcedure sp : filtered.getData()) { System.out.println(sp.getFullyQualifiedName()); } ``` @@ -199,7 +204,7 @@ Returns a paginated list of stored procedure objects. By default, only basic fie - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/retrieve.mdx index d4707331f..3a75248e9 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/retrieve.mdx @@ -16,7 +16,7 @@ Get a single stored procedure by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single stored procedure by its unique ID or fully qualified name. Use `GET /v1/storedProcedures/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the stored procedure (e.g., `snowflake_prod.analytics.public.usp_refresh_analytics`). + Fully qualified name of the stored procedure, for example `snowflake_prod.analytics.public.usp_refresh_analytics`. @@ -51,7 +51,7 @@ configure( # Get by ID sp = StoredProcedures.retrieve("770e8400-e29b-41d4-a716-446655440000") -print(f"{sp.fullyQualifiedName}: {sp.description}") +print(f"{sp.fullyQualifiedName.root}: {sp.name.root}") # Get by ID with fields sp = StoredProcedures.retrieve( @@ -65,31 +65,33 @@ sp = StoredProcedures.retrieve_by_name("snowflake_prod.analytics.public.usp_refr # Get by name with fields sp = StoredProcedures.retrieve_by_name( "snowflake_prod.analytics.public.usp_refresh_analytics", - fields=["owners", "tags", "domain"] + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/storedProcedures/{id} -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.schema.entity.data.StoredProcedure; + +// client is an initialized OpenMetadataClient. // Get by ID -var sp = StoredProcedures.retrieve("770e8400-e29b-41d4-a716-446655440000"); +StoredProcedure sp = client.storedProcedures().get("770e8400-e29b-41d4-a716-446655440000"); // Get by ID with fields -var sp = StoredProcedures.retrieve( +StoredProcedure spWithFields = client.storedProcedures().get( "770e8400-e29b-41d4-a716-446655440000", "owners,tags,storedProcedureCode" ); // Get by fully qualified name -var sp = StoredProcedures.retrieveByName( +StoredProcedure spByName = client.storedProcedures().getByName( "snowflake_prod.analytics.public.usp_refresh_analytics" ); // Get by name with fields -var sp = StoredProcedures.retrieveByName( +StoredProcedure spByNameWithFields = client.storedProcedures().getByName( "snowflake_prod.analytics.public.usp_refresh_analytics", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -223,7 +225,7 @@ Returns a stored procedure object with all requested fields populated. - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/update.mdx index 75a05d6e5..3335fb00a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/update.mdx @@ -20,7 +20,7 @@ Update a stored procedure's properties using JSON Merge Patch. You can update by Use `PATCH /v1/storedProcedures/name/{fqn}` to update by fully qualified name. - Fully qualified name of the stored procedure (e.g., `snowflake_prod.analytics.public.usp_refresh_analytics`). + Fully qualified name of the stored procedure, for example `snowflake_prod.analytics.public.usp_refresh_analytics`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Programming language of the code (e.g., `SQL`, `JavaScript`, `Python`). + Programming language of the code, for example `SQL`, `JavaScript`, `Python`. @@ -58,7 +58,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -72,17 +72,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -108,16 +108,18 @@ sp.storedProcedureCode = { } updated = StoredProcedures.update(sp) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/storedProcedures/{id} -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.schema.entity.data.StoredProcedure; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var sp = StoredProcedures.retrieve("770e8400-e29b-41d4-a716-446655440000"); +StoredProcedure sp = client.storedProcedures().get("770e8400-e29b-41d4-a716-446655440000"); sp.setDescription("Updated: Refreshes materialized analytics views with incremental logic"); -var updated = StoredProcedures.update(sp); +StoredProcedure updated = client.storedProcedures().update("770e8400-e29b-41d4-a716-446655440000", sp); ``` ```bash PATCH /v1/storedProcedures/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/versions.mdx index 3630b6d61..7c2211c3d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/stored-procedures/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/storedProcedures/{id}/versions/{version}` to retrieve a specific ve - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/storedProcedures/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import StoredProcedures @@ -40,28 +42,30 @@ configure( # List all versions versions = StoredProcedures.get_versions("770e8400-e29b-41d4-a716-446655440000") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version sp_v1 = StoredProcedures.get_specific_version( "770e8400-e29b-41d4-a716-446655440000", "0.1" ) -print(f"Original description: {sp_v1.description}") +print(f"Original description: {sp_v1.description.root if sp_v1.description else None}") ``` ```java GET /v1/storedProcedures/{id}/versions -import static org.openmetadata.sdk.fluent.StoredProcedures.*; +import org.openmetadata.schema.entity.data.StoredProcedure; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = StoredProcedures.getVersions("770e8400-e29b-41d4-a716-446655440000"); +EntityHistory history = client.storedProcedures().getVersionList("770e8400-e29b-41d4-a716-446655440000"); -for (var version : history.getVersions()) { - System.out.println("Version: " + version); -} +System.out.println("Total versions: " + history.getVersions().size()); // Get a specific version -var v1 = StoredProcedures.getSpecificVersion( +StoredProcedure v1 = client.storedProcedures().getVersion( "770e8400-e29b-41d4-a716-446655440000", 0.1 ); diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/create.mdx index 6f1b9e302..5c2bf4c12 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/create.mdx @@ -16,7 +16,7 @@ Create a new table within a database schema. - Fully qualified name of the parent DatabaseSchema (e.g., `snowflake_prod.analytics.public`). + Fully qualified name of the parent DatabaseSchema, for example `snowflake_prod.analytics.public`. @@ -28,7 +28,7 @@ Create a new table within a database schema. - Data type of the column (e.g., `INT`, `VARCHAR`, `TIMESTAMP`, `BOOLEAN`, `ARRAY`, `MAP`). + Data type of the column, for example `INT`, `VARCHAR`, `TIMESTAMP`, `BOOLEAN`, `ARRAY`, `MAP`. @@ -36,7 +36,7 @@ Create a new table within a database schema. - Length of the data type (e.g., `256` for `VARCHAR(256)`). + Length of the data type, for example `256` for `VARCHAR(256`). @@ -62,7 +62,7 @@ Create a new table within a database schema. - Data retention period in ISO 8601 duration format (e.g., `P365D`). + Data retention period in ISO 8601 duration format, for example `P365D`. @@ -74,7 +74,7 @@ Create a new table within a database schema. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -83,8 +83,8 @@ Create a new table within a database schema. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -96,11 +96,11 @@ Create a new table within a database schema. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -131,21 +131,23 @@ request = CreateTableRequest( ) table = Tables.create(request) -print(f"Created: {table.fullyQualifiedName}") +print(f"Created: {table.fullyQualifiedName.root}") ``` ```java POST /v1/tables -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.fluent.builders.ColumnBuilder; +import org.openmetadata.sdk.fluent.builders.TableBuilder; -Table table = Tables.builder() +Table table = new TableBuilder(client) .name("customers") - .databaseSchema("snowflake_prod.analytics.public") - .columns(List.of( - column("id", "INT").constraint("PRIMARY_KEY"), - column("name", "VARCHAR").dataLength(256), - column("email", "VARCHAR").dataLength(256), - column("created_at", "TIMESTAMP") - )) + .schemaFQN("snowflake_prod.analytics.public") + .columns( + ColumnBuilder.integer("id").primaryKey(), + ColumnBuilder.varchar("name", 256), + ColumnBuilder.varchar("email", 256), + ColumnBuilder.timestamp("created_at") + ) .create(); ``` @@ -265,7 +267,7 @@ Returns the created table object with all specified properties, system-generated - Type of table (e.g., `Regular`, `View`, `MaterializedView`). + Type of table, for example `Regular`, `View`, `MaterializedView`. @@ -303,7 +305,7 @@ Returns the created table object with all specified properties, system-generated - Type of database service (e.g., Snowflake, BigQuery, PostgreSQL). + Type of database service, for example Snowflake, BigQuery, PostgreSQL. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/custom-metrics.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/custom-metrics.mdx index fa3bc2a23..36f8e912f 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/custom-metrics.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/custom-metrics.mdx @@ -37,6 +37,8 @@ Define custom SQL-based metrics on a table or specific column. Custom metrics ar `DELETE /v1/tables/{id}/customMetric/{metricName}` +To delete a column-level metric, use `DELETE /v1/tables/{id}/customMetric/{columnName}/{metricName}`. + UUID of the table. @@ -47,57 +49,68 @@ Define custom SQL-based metrics on a table or specific column. Custom metrics ar ```python PUT /v1/tables/{id}/customMetric -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Tables +from metadata.generated.schema.api.tests.createCustomMetric import CreateCustomMetricRequest configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add a table-level custom metric -Tables.add_custom_metric(table_id, { - "name": "active_customer_ratio", - "description": "Ratio of active customers to total customers", - "expression": "SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}" -}) +Tables.add_custom_metric(table_id, CreateCustomMetricRequest( + name="active_customer_ratio", + description="Ratio of active customers to total customers", + expression="SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}" +)) # Add a column-level custom metric -Tables.add_custom_metric(table_id, { - "name": "email_domain_count", - "description": "Number of distinct email domains", - "columnName": "email", - "expression": "SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}" -}) - -# Delete a custom metric -Tables.delete_custom_metric(table_id, "active_customer_ratio") +Tables.add_custom_metric(table_id, CreateCustomMetricRequest( + name="email_domain_count", + description="Number of distinct email domains", + columnName="email", + expression="SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}" +)) + +# Delete a table-level custom metric +rest.delete(f"/tables/{table_id}/customMetric/active_customer_ratio") + +# Delete a column-level custom metric +rest.delete(f"/tables/{table_id}/customMetric/email/email_domain_count") ``` ```java PUT /v1/tables/{id}/customMetric -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.tests.CustomMetric; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Add a table-level custom metric -Tables.addCustomMetric(tableId, Map.of( - "name", "active_customer_ratio", - "description", "Ratio of active customers to total customers", - "expression", "SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}" -)); +CustomMetric tableMetric = new CustomMetric() + .withName("active_customer_ratio") + .withDescription("Ratio of active customers to total customers") + .withExpression("SELECT CAST(SUM(CASE WHEN active = true THEN 1 ELSE 0 END) AS FLOAT) / COUNT(*) FROM {table}"); +client.tables().updateCustomMetric(tableId, tableMetric); // Add a column-level custom metric -Tables.addCustomMetric(tableId, Map.of( - "name", "email_domain_count", - "description", "Number of distinct email domains", - "columnName", "email", - "expression", "SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}" -)); - -// Delete a custom metric -Tables.deleteCustomMetric(tableId, "active_customer_ratio"); +CustomMetric columnMetric = new CustomMetric() + .withName("email_domain_count") + .withDescription("Number of distinct email domains") + .withColumnName("email") + .withExpression("SELECT COUNT(DISTINCT SPLIT_PART(email, '@', 2)) FROM {table}"); +client.tables().updateCustomMetric(tableId, columnMetric); + +// Delete a table-level custom metric +client.tables().deleteCustomMetric(tableId, "active_customer_ratio"); + +// Delete a column-level custom metric +client.tables().deleteCustomMetric(tableId, "email/email_domain_count"); ``` ```bash PUT /v1/tables/{id}/customMetric diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/delete.mdx index 7e1167cf9..73e2d1744 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/delete.mdx @@ -28,7 +28,7 @@ Delete a table by ID or fully qualified name. Supports soft delete (default), ha Use `DELETE /v1/tables/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. @@ -67,24 +67,24 @@ Tables.delete( hard_delete=True ) -# Delete by name -Tables.delete_by_name("snowflake_prod.analytics.public.customers") +# Delete by name (look up the ID first) +entity = Tables.retrieve_by_name("snowflake_prod.analytics.public.customers") +Tables.delete(entity.id) # Restore a soft-deleted table Tables.restore("a1b2c3d4-e5f6-7890-abcd-ef1234567890") ``` ```java DELETE /v1/tables/{id} -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. // Soft delete -Tables.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890").execute(); +client.tables().delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Hard delete with recursive -Tables.delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890") - .recursive() - .hardDelete() - .execute(); +client.tables().delete("a1b2c3d4-e5f6-7890-abcd-ef1234567890", Map.of("recursive", "true", "hardDelete", "true")); ``` ```bash DELETE /v1/tables/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/followers-votes.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/followers-votes.mdx index 3d87e3b44..bd7990e1e 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/followers-votes.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/followers-votes.mdx @@ -51,7 +51,7 @@ Manage followers and votes for table entities. Followers receive notifications a ```python PUT /v1/tables/{id}/followers -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Tables configure( @@ -59,39 +59,62 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" user_id = "user-uuid-here" # Add a follower table = Tables.add_followers(table_id, [user_id]) -print(f"Followers: {len(table.followers)}") +print(f"Followers: {len(table.followers.root)}") # Remove a follower table = Tables.remove_followers(table_id, [user_id]) # Add a vote -table = Tables.add_vote(table_id, vote_type="votedUp") +rest.put(f"/tables/{table_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -table = Tables.remove_vote(table_id) +rest.put(f"/tables/{table_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/tables/{id}/followers -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; +String userId = "b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"; // Add a follower -Tables.addFollower(tableId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/tables/" + tableId + "/followers", + UUID.fromString(userId) +); // Remove a follower -Tables.removeFollower(tableId, "user-uuid-here"); +client.getHttpClient().executeForString( + HttpMethod.DELETE, + "/v1/tables/" + tableId + "/followers/" + userId, + null +); // Add a vote -Tables.vote(tableId, "votedUp"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/tables/" + tableId + "/vote", + Map.of("updatedVoteType", "votedUp") +); // Remove a vote -Tables.vote(tableId, "unVoted"); +client.getHttpClient().executeForString( + HttpMethod.PUT, + "/v1/tables/" + tableId + "/vote", + Map.of("updatedVoteType", "unVoted") +); ``` ```bash PUT /v1/tables/{id}/followers diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/import-export.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/import-export.mdx index e915553d3..a97622f8d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/import-export.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/import-export.mdx @@ -14,7 +14,7 @@ Export table metadata (columns, owners, tags, descriptions) to CSV and import ch `GET /v1/tables/name/{fqn}/export` - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. ## Export Async @@ -80,6 +80,8 @@ result = ( ```java GET /v1/tables/name/{fqn}/export import org.openmetadata.sdk.fluent.Tables; +Tables.setDefaultClient(client); + // Synchronous export String csvData = Tables.exportCsv("snowflake_prod.analytics.public.customers") .execute(); @@ -90,15 +92,14 @@ String jobId = Tables.exportCsv("snowflake_prod.analytics.public.customers") .execute(); // Synchronous import (dry run) -String result = Tables.importCsv("snowflake_prod.analytics.public.customers") +String dryRunResult = Tables.importCsv("snowflake_prod.analytics.public.customers") .withData(csvData) - .dryRun(true) + .dryRun() .execute(); // Apply import String result = Tables.importCsv("snowflake_prod.analytics.public.customers") .withData(csvData) - .dryRun(false) .execute(); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/list.mdx index 117acc2d0..0e200b910 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/list.mdx @@ -56,25 +56,30 @@ configure( # List with pagination page = Tables.list(limit=50, fields=["columns", "owners", "tags"]) for t in page.entities: - print(f"{t.fullyQualifiedName} ({len(t.columns or [])} columns)") + print(f"{t.fullyQualifiedName.root} ({len(t.columns or [])} columns)") # List all with auto-pagination all_tables = Tables.list_all(batch_size=100) for table in all_tables: - print(f"{table.fullyQualifiedName}") + print(f"{table.fullyQualifiedName.root}") ``` ```java GET /v1/tables -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // Retrieve by ID -Table table = Tables.retrieve(tableId); +Table table = client.tables().get(tableId); // List tables -var result = Tables.list() - .fields("columns", "owners", "tags") - .limit(50) - .execute(); +ListResponse
result = client.tables().list( + new ListParams() + .setFields("columns,owners,tags") + .setLimit(50) +); for (Table t : result.getData()) { System.out.println(t.getFullyQualifiedName()); @@ -203,7 +208,7 @@ Returns a paginated list of table objects. By default, only basic fields are inc - Type of table (e.g., `Regular`, `View`, `MaterializedView`). + Type of table, for example `Regular`, `View`, `MaterializedView`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/observability.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/observability.mdx index 6ea18c6db..3c6545813 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/observability.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/observability.mdx @@ -25,69 +25,90 @@ Manage pipeline observability data for a table. This tracks which pipelines prod UUID of the table. - - Name of the pipeline. +The request body is a list. Each item describes one pipeline: + + + Reference to the pipeline. Include its `id` (UUID), `type` (`pipeline`), and `fullyQualifiedName`. - - Fully qualified name of the pipeline. + + Type of the pipeline service, such as `Airflow`. - - Status of the last pipeline run: `Successful`, `Failed`, `Pending`, `Aborted`. + + Schedule of the pipeline, as a cron expression. - + Unix timestamp (milliseconds) of the last pipeline run. - - Unix timestamp (milliseconds) of the next scheduled run. + + Status of the last pipeline run: `Successful`, `Failed`, `Pending`, `Skipped`. + + + + Average run time of the pipeline. ```python GET /v1/tables/{id}/pipelineObservability -from metadata.sdk import configure -from metadata.sdk.entities import Tables +from metadata.sdk import configure, client +from metadata.sdk.entities import Pipelines configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" +rest = client().ometa.client -# Get pipeline observability -observability = Tables.get_pipeline_observability(table_id) -for pipeline in observability: - print(f"{pipeline['pipelineName']}: {pipeline['lastRunStatus']}") +table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add pipeline observability -Tables.add_pipeline_observability(table_id, { - "pipelineName": "customer_etl", - "pipelineFQN": "airflow_prod.customer_etl", - "lastRunStatus": "Successful", - "lastRunTimestamp": 1706745600000, - "nextRunTimestamp": 1706832000000 -}) +pipeline = Pipelines.retrieve_by_name("airflow_prod.customer_etl") +rest.put(f"/tables/{table_id}/pipelineObservability", json=[{ + "pipeline": { + "id": str(pipeline.id.root), + "type": "pipeline", + "fullyQualifiedName": "airflow_prod.customer_etl" + }, + "serviceType": "Airflow", + "scheduleInterval": "0 0 * * *", + "lastRunTime": 1706745600000, + "lastRunStatus": "Successful" +}]) + +# Get pipeline observability +observability = rest.get(f"/tables/{table_id}/pipelineObservability") +for item in observability: + print(f"{item['pipeline']['fullyQualifiedName']}: {item['lastRunStatus']}") ``` ```java GET /v1/tables/{id}/pipelineObservability -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.List; +import org.openmetadata.schema.api.services.CreatePipelineService.PipelineServiceType; +import org.openmetadata.schema.entity.data.Pipeline; +import org.openmetadata.schema.type.PipelineObservability; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Get pipeline observability -var observability = Tables.getPipelineObservability(tableId); +List observability = client.tables().getPipelineObservability(tableId); // Add pipeline observability -Tables.addPipelineObservability(tableId, Map.of( - "pipelineName", "customer_etl", - "pipelineFQN", "airflow_prod.customer_etl", - "lastRunStatus", "Successful", - "lastRunTimestamp", 1706745600000L, - "nextRunTimestamp", 1706832000000L -)); +Pipeline pipeline = client.pipelines().getByName("airflow_prod.customer_etl"); + +PipelineObservability item = new PipelineObservability() + .withPipeline(pipeline.getEntityReference()) + .withServiceType(PipelineServiceType.Airflow) + .withScheduleInterval("0 0 * * *") + .withLastRunTime(1706745600000L) + .withLastRunStatus(PipelineObservability.LastRunStatus.SUCCESSFUL); + +client.tables().addPipelineObservability(tableId, List.of(item)); ``` ```bash GET /v1/tables/{id}/pipelineObservability @@ -99,25 +120,35 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/pipelineObse curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/pipelineObservability" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ - -d '{ - "pipelineName": "agent_metrics_etl", - "pipelineFQN": "airflow_prod.agent_metrics_etl", - "lastRunStatus": "Successful", - "lastRunTimestamp": 1769982651320, - "nextRunTimestamp": 1770069051320 - }' + -d '[{ + "pipeline": { + "id": "9a1d3c52-6f0b-4c1e-8a57-2b6f4e0d7c11", + "type": "pipeline", + "fullyQualifiedName": "airflow_prod.agent_metrics_etl" + }, + "serviceType": "Airflow", + "scheduleInterval": "0 0 * * *", + "lastRunTime": 1769982651320, + "lastRunStatus": "Successful" + }]' ``` ```json Response (Get Pipeline Observability) -{ - "pipelineName": "customer_etl", - "pipelineFQN": "airflow_prod.customer_etl", - "lastRunStatus": "Successful", - "lastRunTimestamp": 1706745600000, - "nextRunTimestamp": 1706832000000 -} +[ + { + "pipeline": { + "id": "9a1d3c52-6f0b-4c1e-8a57-2b6f4e0d7c11", + "type": "pipeline", + "fullyQualifiedName": "airflow_prod.customer_etl" + }, + "serviceType": "Airflow", + "scheduleInterval": "0 0 * * *", + "lastRunTime": 1706745600000, + "lastRunStatus": "Successful" + } +] ``` @@ -125,30 +156,34 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/pipel ## Returns -**Get** returns pipeline observability data associated with the table. +**Get** returns a list with one item for each pipeline linked to the table. -**Add** returns the updated pipeline observability data. +**Add** returns the updated table. ## Response - - Name of the pipeline. + + Reference to the pipeline, with its `id`, `type`, and `fullyQualifiedName`. - - Fully qualified name of the pipeline. + + Type of the pipeline service. - - Status of the last run. + + Schedule of the pipeline, as a cron expression. - + Unix timestamp of the last run in milliseconds. - - Unix timestamp of the next scheduled run in milliseconds. + + Status of the last run. + + + + Average run time of the pipeline. --- diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/profiler.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/profiler.mdx index 5a82e3315..360a5861d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/profiler.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/profiler.mdx @@ -2,7 +2,7 @@ title: Table Profiler description: Manage profiler configuration and retrieve profile data for tables sidebarTitle: Table Profiler -api: GET /v1/tables/{id}/profilerConfig +api: GET /v1/tables/{id}/tableProfilerConfig --- # Table Profiler @@ -11,7 +11,7 @@ Manage the profiler configuration for a table and retrieve profiling results inc ## Get Profiler Config -`GET /v1/tables/{id}/profilerConfig` +`GET /v1/tables/{id}/tableProfilerConfig` UUID of the table. @@ -19,7 +19,7 @@ Manage the profiler configuration for a table and retrieve profiling results inc ## Set Profiler Config -`PUT /v1/tables/{id}/profilerConfig` +`PUT /v1/tables/{id}/tableProfilerConfig` UUID of the table. @@ -61,7 +61,7 @@ Manage the profiler configuration for a table and retrieve profiling results inc ## Delete Profiler Config -`DELETE /v1/tables/{id}/profilerConfig` +`DELETE /v1/tables/{id}/tableProfilerConfig` UUID of the table. @@ -98,8 +98,8 @@ Returns system-level profiling results (DML operations, rows affected). -```python GET /v1/tables/{id}/profilerConfig -from metadata.sdk import configure +```python GET /v1/tables/{id}/tableProfilerConfig +from metadata.sdk import configure, client from metadata.sdk.entities import Tables configure( @@ -107,15 +107,18 @@ configure( jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Get profiler config -config = Tables.get_profiler_config(table_id) -sample_config = config.get("profileSampleConfig", {}).get("config", {}) -print(f"Sample: {sample_config.get('profileSample')}%") +table = Tables.retrieve(table_id, fields=["tableProfilerConfig"]) +config = table.tableProfilerConfig +if config and config.profileSampleConfig: + print(f"Sample: {config.profileSampleConfig.config.profileSample}%") # Set profiler config - profile 50% of rows -Tables.set_profiler_config(table_id, { +rest.put(f"/tables/{table_id}/tableProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": {"profileSample": 50, "profileSampleType": "PERCENTAGE"} @@ -125,7 +128,7 @@ Tables.set_profiler_config(table_id, { }) # Set profiler config with specific column metrics -Tables.set_profiler_config(table_id, { +rest.put(f"/tables/{table_id}/tableProfilerConfig", json={ "profileSampleConfig": { "sampleConfigType": "STATIC", "config": {"profileSample": 100, "profileSampleType": "PERCENTAGE"} @@ -137,38 +140,50 @@ Tables.set_profiler_config(table_id, { }) # Delete profiler config -Tables.delete_profiler_config(table_id) +rest.delete(f"/tables/{table_id}/tableProfilerConfig") ``` -```java GET /v1/tables/{id}/profilerConfig -import static org.openmetadata.sdk.fluent.Tables.*; +```java GET /v1/tables/{id}/tableProfilerConfig +import java.util.List; +import java.util.Map; +import org.openmetadata.schema.type.ProfileSampleConfig; +import org.openmetadata.schema.type.TableProfilerConfig; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Get profiler config -var config = Tables.getProfilerConfig(tableId); +TableProfilerConfig profilerConfig = client.tables() + .get(tableId, "tableProfilerConfig") + .getTableProfilerConfig(); // Set profiler config -Tables.setProfilerConfig(tableId, Map.of( - "profileSampleConfig", Map.of( - "sampleConfigType", "STATIC", - "config", Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE") - ), - "sampleDataCount", 200, - "excludeColumns", List.of("created_at") -)); +TableProfilerConfig newConfig = new TableProfilerConfig() + .withProfileSampleConfig(new ProfileSampleConfig() + .withSampleConfigType(ProfileSampleConfig.SampleConfigType.STATIC) + .withConfig(Map.of("profileSample", 50, "profileSampleType", "PERCENTAGE"))) + .withSampleDataCount(200) + .withExcludeColumns(List.of("created_at")); +client.tables().updateProfilerConfig(tableId, newConfig); // Delete profiler config -Tables.deleteProfilerConfig(tableId); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/tables/" + tableId + "/tableProfilerConfig", + null, + Void.class +); ``` -```bash GET /v1/tables/{id}/profilerConfig +```bash GET /v1/tables/{id}/tableProfilerConfig # Get profiler config -curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profilerConfig" \ +curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/tableProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Set profiler config -curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profilerConfig" \ +curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/tableProfilerConfig" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -181,7 +196,7 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profi }' # Delete profiler config -curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/profilerConfig" \ +curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/tableProfilerConfig" \ -H "Authorization: Bearer {access_token}" # Get table profile @@ -201,12 +216,16 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/systemProfil ```json Response (Profiler Config) { - "profileSampleConfig": { - "sampleConfigType": "STATIC", - "config": {"profileSample": 50, "profileSampleType": "PERCENTAGE"} - }, - "sampleDataCount": 200, - "excludeColumns": ["created_at"] + "id": "455e3d9d-dbbf-455e-b3be-7191daa825f3", + "name": "agent_performance", + "tableProfilerConfig": { + "profileSampleConfig": { + "sampleConfigType": "STATIC", + "config": {"profileSample": 50, "profileSampleType": "PERCENTAGE"} + }, + "sampleDataCount": 200, + "excludeColumns": ["created_at"] + } } ``` @@ -215,11 +234,11 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/systemProfil ## Returns -**Get profiler config** returns the profiler configuration object. +**Get profiler config** returns the table. The configuration is in its `tableProfilerConfig` field. -**Set profiler config** returns the updated profiler configuration. +**Set profiler config** returns the updated table. -**Delete profiler config** returns no content (204). +**Delete profiler config** returns the updated table, without a profiler configuration. **Get table profile** returns table-level metrics (row count, size, etc.). @@ -229,6 +248,8 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/systemProfil ## Response (Profiler Config) +These fields are inside the table's `tableProfilerConfig` field. + How much data is profiled. Contains `sampleConfigType` (`STATIC` or `DYNAMIC`) and a `config` object holding the settings for that type. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/relationships.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/relationships.mdx index 41d79793f..f68fc13c9 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/relationships.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/relationships.mdx @@ -20,7 +20,7 @@ Record join information between this table and other tables. - Start date for the join period (ISO 8601 format). + Start date for the join period (ISO 8601 format). The period must fall within the past 30 days, ending today. In the examples, `{start_date}` stands for a date in this range, such as today's date. @@ -40,7 +40,7 @@ Record join information between this table and other tables. - FQN of the joined column (e.g., `snowflake_prod.analytics.public.orders.customer_id`). + FQN of the joined column, for example `snowflake_prod.analytics.public.orders.customer_id`. @@ -62,7 +62,7 @@ Set the data model (dbt or similar) associated with this table. - Type of data model: `DBT`, `LookML`. + Type of data model: `DBT` or `DDL`. @@ -74,7 +74,7 @@ Set the data model (dbt or similar) associated with this table. - Column descriptions and metadata from the data model. + Column descriptions and metadata from the data model. Each column needs a `name` and a `dataType`. ## Get Columns @@ -97,20 +97,23 @@ Retrieve column information with optional pagination. ```python PUT /v1/tables/{id}/joins -from metadata.sdk import configure -from metadata.sdk.entities import Tables +from datetime import date + +from metadata.sdk import configure, client configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client + table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add join information -Tables.add_joins(table_id, { - "startDate": "2024-01-01", - "dayCount": 30, +rest.put(f"/tables/{table_id}/joins", json={ + "startDate": date.today().isoformat(), + "dayCount": 1, "columnJoins": [ { "columnName": "id", @@ -125,47 +128,52 @@ Tables.add_joins(table_id, { }) # Set data model -Tables.set_data_model(table_id, { +rest.put(f"/tables/{table_id}/dataModel", json={ "modelType": "DBT", "description": "Customer dimension table built from raw events", "sql": "SELECT id, name, email, created_at FROM raw.customers WHERE active = true", "columns": [ - {"name": "id", "description": "Primary key from source"}, - {"name": "name", "description": "Customer full name"}, - {"name": "email", "description": "Verified email address"}, - {"name": "created_at", "description": "First seen timestamp"} + {"name": "id", "dataType": "INT", "description": "Primary key from source"}, + {"name": "name", "dataType": "VARCHAR", "description": "Customer full name"}, + {"name": "email", "dataType": "VARCHAR", "description": "Verified email address"}, + {"name": "created_at", "dataType": "TIMESTAMP", "description": "First seen timestamp"} ] }) ``` ```java PUT /v1/tables/{id}/joins -import static org.openmetadata.sdk.fluent.Tables.*; +import java.time.LocalDate; +import java.util.List; +import org.openmetadata.schema.type.ColumnJoin; +import org.openmetadata.schema.type.DataModel; +import org.openmetadata.schema.type.JoinedWith; +import org.openmetadata.schema.type.TableJoins; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Add join information -Tables.addJoins(tableId, Map.of( - "startDate", "2024-01-01", - "dayCount", 30, - "columnJoins", List.of( - Map.of( - "columnName", "id", - "joinedWith", List.of( - Map.of( - "fullyQualifiedName", "snowflake_prod.analytics.public.orders.customer_id", - "joinCount", 1542 - ) - ) - ) - ) -)); +TableJoins joins = new TableJoins() + .withStartDate(LocalDate.now().toString()) + .withDayCount(1) + .withColumnJoins(List.of( + new ColumnJoin() + .withColumnName("id") + .withJoinedWith(List.of( + new JoinedWith() + .withFullyQualifiedName("snowflake_prod.analytics.public.orders.customer_id") + .withJoinCount(1542) + )) + )); +client.tables().updateJoins(tableId, joins); // Set data model -Tables.setDataModel(tableId, Map.of( - "modelType", "DBT", - "description", "Customer dimension table built from raw events", - "sql", "SELECT id, name, email, created_at FROM raw.customers WHERE active = true" -)); +DataModel dataModel = new DataModel() + .withModelType(DataModel.ModelType.DBT) + .withDescription("Customer dimension table built from raw events") + .withSql("SELECT id, name, email, created_at FROM raw.customers WHERE active = true"); +client.tables().updateDataModel(tableId, dataModel); ``` ```bash PUT /v1/tables/{id}/joins @@ -174,8 +182,8 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/joins -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ - "startDate": "2024-01-01", - "dayCount": 30, + "startDate": "{start_date}", + "dayCount": 1, "columnJoins": [ { "columnName": "agent_id", @@ -208,8 +216,8 @@ curl "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/columns?limi ```json Response (Add Joins) { - "startDate": "2024-01-01", - "dayCount": 30, + "startDate": "{start_date}", + "dayCount": 1, "columnJoins": [ { "columnName": "agent_id", diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/retrieve.mdx index 4ef5e0c6c..0ecb28395 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/retrieve.mdx @@ -28,7 +28,7 @@ Get a single table by its unique ID or fully qualified name. Use `GET /v1/tables/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. @@ -51,7 +51,7 @@ configure( # Get by ID table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890") -print(f"{table.fullyQualifiedName}: {table.description}") +print(f"{table.fullyQualifiedName.root}: {table.name.root}") # Get by ID with fields table = Tables.retrieve( @@ -70,13 +70,15 @@ table = Tables.retrieve_by_name( ``` ```java GET /v1/tables/{id} -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; + +// client is an initialized OpenMetadataClient. // Get by ID -Table table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +Table table = client.tables().get("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Get by fully qualified name -Table table = Tables.retrieveByName("snowflake_prod.analytics.public.customers"); +Table tableByName = client.tables().getByName("snowflake_prod.analytics.public.customers"); ``` ```bash GET /v1/tables/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/sample-data.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/sample-data.mdx index a41bc9edd..834f6d795 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/sample-data.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/sample-data.mdx @@ -26,17 +26,7 @@ Manage sample data rows for a table. Sample data provides a preview of the table - Array of column references describing the sample data columns. - - - - Name of the column. - - - - Data type of the column. - - + Array of column names, in the same order as the values in each row. @@ -53,65 +43,68 @@ Manage sample data rows for a table. Sample data provides a preview of the table ```python GET /v1/tables/{id}/sampleData -from metadata.sdk import configure +from metadata.sdk import configure, client from metadata.sdk.entities import Tables +from metadata.generated.schema.entity.data.table import TableData configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" +rest = client().ometa.client -# Get sample data -sample = Tables.get_sample_data(table_id) -for row in sample.get("rows", []): - print(row) +table_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890" # Add sample data -Tables.add_sample_data(table_id, { - "columns": [ - {"name": "id", "dataType": "INT"}, - {"name": "name", "dataType": "VARCHAR"}, - {"name": "email", "dataType": "VARCHAR"}, - {"name": "created_at", "dataType": "TIMESTAMP"} - ], - "rows": [ +Tables.add_sample_data(table_id, TableData( + columns=["id", "name", "email", "created_at"], + rows=[ [1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"], [2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"], [3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z"] ] -}) +)) + +# Get sample data +table = Tables.get_sample_data(table_id) +for row in table.sampleData.rows: + print(row) # Delete sample data -Tables.delete_sample_data(table_id) +rest.delete(f"/tables/{table_id}/sampleData") ``` ```java GET /v1/tables/{id}/sampleData -import static org.openmetadata.sdk.fluent.Tables.*; +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.TableData; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. String tableId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"; // Get sample data -var sample = Tables.getSampleData(tableId); +Table sample = client.tables().getSampleData(tableId); // Add sample data -Tables.addSampleData(tableId, Map.of( - "columns", List.of( - Map.of("name", "id", "dataType", "INT"), - Map.of("name", "name", "dataType", "VARCHAR"), - Map.of("name", "email", "dataType", "VARCHAR"), - Map.of("name", "created_at", "dataType", "TIMESTAMP") - ), - "rows", List.of( - List.of(1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"), - List.of(2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"), - List.of(3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z") - ) -)); +TableData sampleData = new TableData() + .withColumns(List.of("id", "name", "email", "created_at")) + .withRows(List.of( + List.of(1, "Alice Johnson", "alice@example.com", "2024-01-15T10:30:00Z"), + List.of(2, "Bob Smith", "bob@example.com", "2024-02-20T14:15:00Z"), + List.of(3, "Carol Williams", "carol@example.com", "2024-03-10T09:45:00Z") + )); +client.tables().updateSampleData(tableId, sampleData); // Delete sample data -Tables.deleteSampleData(tableId); +client.getHttpClient().execute( + HttpMethod.DELETE, + "/v1/tables/" + tableId + "/sampleData", + null, + Void.class +); ``` ```bash GET /v1/tables/{id}/sampleData @@ -124,10 +117,7 @@ curl -X PUT "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sampl -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ - "columns": [ - {"name": "agent_id", "dataType": "VARCHAR"}, - {"name": "performance_score", "dataType": "DECIMAL"} - ], + "columns": ["agent_id", "performance_score"], "rows": [ ["AGT-001", 92.5], ["AGT-002", 87.3], @@ -144,15 +134,16 @@ curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sa ```json Response (Get Sample Data) { - "columns": [ - {"name": "agent_id", "dataType": "VARCHAR"}, - {"name": "performance_score", "dataType": "DECIMAL"} - ], - "rows": [ - ["AGT-001", 92.5], - ["AGT-002", 87.3], - ["AGT-003", 95.1] - ] + "id": "455e3d9d-dbbf-455e-b3be-7191daa825f3", + "name": "agent_performance", + "sampleData": { + "columns": ["agent_id", "performance_score"], + "rows": [ + ["AGT-001", 92.5], + ["AGT-002", 87.3], + ["AGT-003", 95.1] + ] + } } ``` @@ -161,26 +152,16 @@ curl -X DELETE "{base_url}/api/v1/tables/455e3d9d-dbbf-455e-b3be-7191daa825f3/sa ## Returns -**Get** returns the sample data object with columns and rows arrays. +**Get** returns the table. The sample data is in its `sampleData` field, with `columns` and `rows` arrays. -**Add** returns the updated sample data object. +**Add** returns the updated table. -**Delete** returns no content (204). +**Delete** returns the updated table, without sample data. ## Response - Array of column definitions for the sample data. - - - - Column name. - - - - Data type of the column. - - + Array of column names for the sample data. This field is inside `sampleData`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/update.mdx index a11af994f..10aa7ed85 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/update.mdx @@ -20,7 +20,7 @@ Update a table's properties using JSON Merge Patch. You can update by ID or by f Use `PATCH /v1/tables/name/{fqn}` to update by fully qualified name. - Fully qualified name of the table (e.g., `snowflake_prod.analytics.public.customers`). + Fully qualified name of the table, for example `snowflake_prod.analytics.public.customers`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -58,11 +58,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -75,8 +75,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. Updated column definitions. Use this to update column descriptions, tags, or add new columns. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -98,16 +98,18 @@ table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890") table.description = "Updated customer master data table with PII fields" updated = Tables.update(table) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/tables/{id} -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -Table table = Tables.retrieve("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +Table table = client.tables().get("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); table.setDescription("Updated customer master data table with PII fields"); -Table updated = Tables.update(table); +Table updated = client.tables().update("a1b2c3d4-e5f6-7890-abcd-ef1234567890", table); ``` ```bash PATCH /v1/tables/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/versions.mdx index e842e5181..69de38be5 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/tables/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/tables/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/tables/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Tables @@ -40,26 +42,30 @@ configure( # List all versions versions = Tables.get_versions("a1b2c3d4-e5f6-7890-abcd-ef1234567890") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version table_v1 = Tables.get_specific_version( "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "0.1" ) -print(f"Original description: {table_v1.description}") +print(f"Original description: {table_v1.description.root if table_v1.description else None}") ``` ```java GET /v1/tables/{id}/versions -import static org.openmetadata.sdk.fluent.Tables.*; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var versions = Tables.getVersions("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +EntityHistory versions = client.tables().getVersionList("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); // Get a specific version -Table v1 = Tables.getSpecificVersion( +Table v1 = client.tables().getVersion( "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "0.1" + 0.1 ); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/create.mdx index 46dc41b30..42f31b955 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/create.mdx @@ -16,7 +16,7 @@ Create a new topic within a messaging service. - Fully qualified name of the parent MessagingService (e.g., `sample_kafka`). + Fully qualified name of the parent MessagingService, for example `sample_kafka`. @@ -24,7 +24,7 @@ Create a new topic within a messaging service. - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`, `Other`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`, `Other`. @@ -38,7 +38,7 @@ Create a new topic within a messaging service. - Array of cleanup policies for the topic (e.g., `delete`, `compact`). + Array of cleanup policies for the topic, for example `delete`, `compact`. @@ -70,7 +70,7 @@ Create a new topic within a messaging service. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -79,8 +79,8 @@ Create a new topic within a messaging service. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -92,11 +92,11 @@ Create a new topic within a messaging service. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -107,13 +107,22 @@ Create a new topic within a messaging service. ```python POST /v1/topics -from metadata.sdk import configure -from metadata.sdk.entities import Topics +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata from metadata.generated.schema.api.data.createTopic import CreateTopicRequest -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) request = CreateTopicRequest( @@ -132,23 +141,28 @@ request = CreateTopicRequest( retentionSize=-1 ) -topic = Topics.create(request) -print(f"Created: {topic.fullyQualifiedName}") +topic = metadata.create_or_update(request) +print(f"Created: {topic.fullyQualifiedName.root}") ``` ```java POST /v1/topics -import static org.openmetadata.sdk.fluent.Topics.*; - -// Create using builder pattern -var topic = Topics.builder() - .name("address_book") - .displayName("Address Book") - .service("sample_kafka") - .description("All Protobuf record related events gets captured in this topic") - .partitions(1) - .cleanupPolicies(List.of("delete")) - .replicationFactor(1) - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateTopic; +import org.openmetadata.schema.entity.data.Topic; +import org.openmetadata.schema.type.topic.CleanupPolicy; + +// client is an initialized OpenMetadataClient. + +CreateTopic request = new CreateTopic() + .withName("address_book") + .withDisplayName("Address Book") + .withService("sample_kafka") + .withDescription("All Protobuf record related events gets captured in this topic") + .withPartitions(1) + .withCleanupPolicies(List.of(CleanupPolicy.DELETE)) + .withReplicationFactor(1); + +Topic topic = client.topics().create(request); ``` ```bash POST /v1/topics @@ -279,7 +293,7 @@ Returns the created topic object with all specified properties and system-genera - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`. @@ -313,7 +327,7 @@ Returns the created topic object with all specified properties and system-genera - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. @@ -325,7 +339,7 @@ Returns the created topic object with all specified properties and system-genera - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -347,11 +361,11 @@ Returns the created topic object with all specified properties and system-genera - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/delete.mdx index c257242e7..ec7656a55 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/delete.mdx @@ -28,7 +28,7 @@ Delete a topic by ID or fully qualified name. Supports soft delete (default), ha Use `DELETE /v1/topics/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the topic (e.g., `sample_kafka.address_book`). + Fully qualified name of the topic, for example `sample_kafka.address_book`. @@ -49,53 +49,64 @@ Use `PUT /v1/topics/restore` to restore a soft-deleted topic. ```python DELETE /v1/topics/{id} -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Soft delete by ID -Topics.delete("0a021819-982e-4ee4-a5a2-4af30eaa3016") +metadata.delete(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") # Hard delete -Topics.delete( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", +metadata.delete( + entity=Topic, + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", hard_delete=True ) # Delete by name -Topics.delete_by_name("sample_kafka.address_book") +topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book") +metadata.delete(entity=Topic, entity_id=topic.id) # Delete by name with options -Topics.delete_by_name( - "sample_kafka.address_book", - hard_delete=True -) +topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book") +metadata.delete(entity=Topic, entity_id=topic.id, hard_delete=True) # Restore a soft-deleted topic -Topics.restore("0a021819-982e-4ee4-a5a2-4af30eaa3016") +metadata.restore(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") ``` ```java DELETE /v1/topics/{id} -import static org.openmetadata.sdk.fluent.Topics.*; +import java.util.Map; +import org.openmetadata.schema.entity.data.Topic; + +// client is an initialized OpenMetadataClient. // Soft delete -Topics.delete("0a021819-982e-4ee4-a5a2-4af30eaa3016").execute(); +client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016"); // Hard delete -Topics.delete("0a021819-982e-4ee4-a5a2-4af30eaa3016") - .hardDelete() - .execute(); +client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016", Map.of("hardDelete", "true")); -// Delete by name -Topics.deleteByName("sample_kafka.address_book") - .execute(); +// Delete by name (look up the ID first) +Topic topic = client.topics().getByName("sample_kafka.address_book"); +client.topics().delete(topic.getId()); // Restore -Topics.restore("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +client.topics().restore("0a021819-982e-4ee4-a5a2-4af30eaa3016"); ``` ```bash DELETE /v1/topics/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/followers-votes.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/followers-votes.mdx index b9bec718f..331d96932 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/followers-votes.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/followers-votes.mdx @@ -51,47 +51,66 @@ Manage followers and votes for topic entities. ```python PUT /v1/topics/{id}/followers -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) topic_id = "0a021819-982e-4ee4-a5a2-4af30eaa3016" user_id = "user-uuid-here" # Add a follower -topic = Topics.add_followers(topic_id, [user_id]) -print(f"Followers: {len(topic.followers)}") +metadata.client.put(f"/topics/{topic_id}/followers", json=user_id) +topic = metadata.get_by_id(entity=Topic, entity_id=topic_id, fields=["followers"]) +print(f"Followers: {len(topic.followers.root)}") # Remove a follower -topic = Topics.remove_followers(topic_id, [user_id]) +metadata.client.delete(f"/topics/{topic_id}/followers/{user_id}") # Add a vote -topic = Topics.add_vote(topic_id, vote_type="votedUp") +metadata.client.put(f"/topics/{topic_id}/vote", json={"updatedVoteType": "votedUp"}) # Remove a vote -topic = Topics.remove_vote(topic_id) +metadata.client.put(f"/topics/{topic_id}/vote", json={"updatedVoteType": "unVoted"}) ``` ```java PUT /v1/topics/{id}/followers -import static org.openmetadata.sdk.fluent.Topics.*; +import java.util.Map; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpClient; +import org.openmetadata.sdk.network.HttpMethod; + +// client is an initialized OpenMetadataClient. + +HttpClient http = client.getHttpClient(); String topicId = "0a021819-982e-4ee4-a5a2-4af30eaa3016"; +UUID userId = UUID.fromString("b6f7a1e2-3c4d-4e5f-8a9b-0c1d2e3f4a5b"); // Add a follower -Topics.addFollower(topicId, "user-uuid-here"); +http.executeForString(HttpMethod.PUT, "/v1/topics/" + topicId + "/followers", userId); // Remove a follower -Topics.removeFollower(topicId, "user-uuid-here"); +http.executeForString(HttpMethod.DELETE, "/v1/topics/" + topicId + "/followers/" + userId, null); // Add a vote -Topics.vote(topicId, "votedUp"); +http.executeForString(HttpMethod.PUT, "/v1/topics/" + topicId + "/vote", Map.of("updatedVoteType", "votedUp")); // Remove a vote -Topics.vote(topicId, "unVoted"); +http.executeForString(HttpMethod.PUT, "/v1/topics/" + topicId + "/vote", Map.of("updatedVoteType", "unVoted")); ``` ```bash PUT /v1/topics/{id}/followers diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/list.mdx index d50439b00..e45df3cc7 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/list.mdx @@ -37,59 +37,73 @@ List all topics with optional filtering and pagination. ```python GET /v1/topics -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List first page -topics = Topics.list(limit=50) -for t in topics.data: - print(f"{t.fullyQualifiedName}") +topics = metadata.list_entities(entity=Topic, limit=50) +for topic in topics.entities: + print(f"{topic.fullyQualifiedName.root}") # List all with auto-pagination -for t in Topics.list_all(): - print(f"{t.fullyQualifiedName}") +for topic in metadata.list_all_entities(entity=Topic): + print(f"{topic.fullyQualifiedName.root}") # Filter by service -topics = Topics.list( - service="sample_kafka", - fields=["owners", "tags", "domain"], +topics = metadata.list_entities( + entity=Topic, + fields=["owners", "tags", "domains"], + params={"service": "sample_kafka"}, limit=50 ) -for t in topics.data: - print(f"{t.fullyQualifiedName}") - if t.owners: - print(f" Owners: {[o.name for o in t.owners]}") - if t.tags: - print(f" Tags: {[t.tagFQN for t in t.tags]}") +for topic in topics.entities: + print(f"{topic.fullyQualifiedName.root}") + if topic.owners: + print(f" Owners: {[o.name for o in topic.owners.root]}") + if topic.tags: + print(f" Tags: {[tag.tagFQN.root for tag in topic.tags]}") ``` ```java GET /v1/topics -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; +import org.openmetadata.sdk.models.ListParams; +import org.openmetadata.sdk.models.ListResponse; + +// client is an initialized OpenMetadataClient. // List first page -var result = Topics.list() - .limit(50) - .execute(); +ListResponse firstPage = client.topics().list(new ListParams().setLimit(50)); -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +for (Topic item : firstPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by service with fields -var result = Topics.list() - .service("sample_kafka") - .fields("owners", "tags", "domain") - .limit(50) - .execute(); - -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +ListResponse filtered = client.topics().list( + new ListParams() + .setService("sample_kafka") + .setFields("owners,tags,domains") + .setLimit(50) +); + +for (Topic item : filtered.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` @@ -193,7 +207,7 @@ Returns a paginated list of topic objects. By default, only basic fields are inc - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/retrieve.mdx index 8b5b9f6ba..f12f32e8d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/retrieve.mdx @@ -16,7 +16,7 @@ Get a single topic by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,followers,votes,extension,domains,sourceHash`). + Comma-separated list of fields to include, for example `owners,tags,followers,votes,extension,domains,sourceHash`. @@ -28,7 +28,7 @@ Get a single topic by its unique ID or fully qualified name. Use `GET /v1/topics/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the topic (e.g., `sample_kafka.address_book`). + Fully qualified name of the topic, for example `sample_kafka.address_book`. @@ -41,55 +41,67 @@ Use `GET /v1/topics/name/{fqn}` to retrieve by fully qualified name. ```python GET /v1/topics/{id} -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Get by ID -topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016") -print(f"{topic.fullyQualifiedName}: {topic.description}") +topic = metadata.get_by_id(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") +print(f"{topic.fullyQualifiedName.root}: {topic.description.root}") # Get by ID with fields -topic = Topics.retrieve( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", +topic = metadata.get_by_id( + entity=Topic, + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", fields=["owners", "tags", "messageSchema"] ) # Get by fully qualified name -topic = Topics.retrieve_by_name("sample_kafka.address_book") +topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book") # Get by name with fields -topic = Topics.retrieve_by_name( - "sample_kafka.address_book", - fields=["owners", "tags", "domain"] +topic = metadata.get_by_name( + entity=Topic, + fqn="sample_kafka.address_book", + fields=["owners", "tags", "domains"] ) ``` ```java GET /v1/topics/{id} -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; + +// client is an initialized OpenMetadataClient. // Get by ID -var topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +Topic topic = client.topics().get("0a021819-982e-4ee4-a5a2-4af30eaa3016"); // Get by ID with fields -var topic = Topics.retrieve( +Topic topicWithFields = client.topics().get( "0a021819-982e-4ee4-a5a2-4af30eaa3016", "owners,tags,messageSchema" ); // Get by fully qualified name -var topic = Topics.retrieveByName( - "sample_kafka.address_book" -); +Topic topicByName = client.topics().getByName("sample_kafka.address_book"); // Get by name with fields -var topic = Topics.retrieveByName( +Topic topicByNameWithFields = client.topics().getByName( "sample_kafka.address_book", - "owners,tags,domain" + "owners,tags,domains" ); ``` @@ -219,7 +231,7 @@ Returns a topic object with all requested fields populated. - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`. @@ -233,7 +245,7 @@ Returns a topic object with all requested fields populated. - Type of messaging service (e.g., Kafka, Redpanda, Kinesis). + Type of messaging service, for example Kafka, Redpanda, Kinesis. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/update.mdx index 2ef93788f..23e3ae18d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/update.mdx @@ -20,7 +20,7 @@ Update a topic's properties using JSON Merge Patch. You can update by ID or by f Use `PATCH /v1/topics/name/{fqn}` to update by fully qualified name. - Fully qualified name of the topic (e.g., `sample_kafka.address_book`). + Fully qualified name of the topic, for example `sample_kafka.address_book`. ## Body Parameters @@ -40,7 +40,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of schema (e.g., `Avro`, `Protobuf`, `JSON`, `Other`). + Type of schema, for example `Avro`, `Protobuf`, `JSON`, `Other`. @@ -58,7 +58,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -72,17 +72,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -91,33 +91,47 @@ Send a JSON object with the fields to update. Only provided fields are changed. ```python PATCH /v1/topics/{id} -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic +from metadata.generated.schema.type.schema import SchemaType, Topic as TopicSchema + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # Retrieve, modify, and update -topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016") -topic.description = "Updated: All Protobuf record events captured with enhanced schema" -topic.messageSchema = { - "schemaType": "Protobuf", - "schemaText": "syntax = \"proto3\";\npackage tutorial;\nmessage Person { ... }" -} -updated = Topics.update(topic) +topic = metadata.get_by_id(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016") +modified = topic.model_copy(deep=True) +modified.description = "Updated: All Protobuf record events captured with enhanced schema" +modified.messageSchema = TopicSchema( + schemaType=SchemaType.Protobuf, + schemaText="syntax = \"proto3\";\npackage tutorial;\nmessage Person { ... }" +) +updated = metadata.patch(entity=Topic, source=topic, destination=modified) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/topics/{id} -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; + +// client is an initialized OpenMetadataClient. // Retrieve, modify, and update -var topic = Topics.retrieve("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +Topic topic = client.topics().get("0a021819-982e-4ee4-a5a2-4af30eaa3016"); topic.setDescription("Updated: All Protobuf record events captured with enhanced schema"); -var updated = Topics.update(topic); +Topic updated = client.topics().update(topic.getId(), topic); ``` ```bash PATCH /v1/topics/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/versions.mdx index c2fdf49fd..ad2bb1382 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-assets/topics/versions.mdx @@ -24,47 +24,62 @@ Use `GET /v1/topics/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/topics/{id}/versions -from metadata.sdk import configure -from metadata.sdk.entities import Topics - -configure( - host="https://your-company.open-metadata.org/api", - jwt_token="your-jwt-token" +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + AuthProvider, + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) +from metadata.ingestion.ometa.ometa_api import OpenMetadata +from metadata.generated.schema.entity.data.topic import Topic + +metadata = OpenMetadata( + OpenMetadataConnection( + hostPort="https://your-company.open-metadata.org/api", + authProvider=AuthProvider.openmetadata, + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), + ) ) # List all versions -versions = Topics.get_versions("0a021819-982e-4ee4-a5a2-4af30eaa3016") -for v in versions: - print(f"Version {v.version}: {v.description}") +history = metadata.list_versions( + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", + entity=Topic +) +for v in history.versions: + topic_version = Topic.model_validate_json(v) + print(f"Version {topic_version.version.root}: {topic_version.description.root}") # Get a specific version -topic_v1 = Topics.get_specific_version( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", - "0.1" +topic_v1 = metadata.get_entity_version( + entity=Topic, + entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016", + version="0.1" ) -print(f"Original description: {topic_v1.description}") +print(f"Original description: {topic_v1.description.root}") ``` ```java GET /v1/topics/{id}/versions -import static org.openmetadata.sdk.fluent.Topics.*; +import org.openmetadata.schema.entity.data.Topic; +import org.openmetadata.schema.type.EntityHistory; + +// client is an initialized OpenMetadataClient. // List all versions -var history = Topics.getVersions("0a021819-982e-4ee4-a5a2-4af30eaa3016"); +EntityHistory history = client.topics().getVersionList("0a021819-982e-4ee4-a5a2-4af30eaa3016"); -for (var version : history.getVersions()) { +for (Object version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Topics.getSpecificVersion( - "0a021819-982e-4ee4-a5a2-4af30eaa3016", - 0.1 -); +Topic v1 = client.topics().getVersion("0a021819-982e-4ee4-a5a2-4af30eaa3016", 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-contracts/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-contracts/delete.mdx index e58a26fbe..5b5f8af11 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-contracts/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-contracts/delete.mdx @@ -67,7 +67,7 @@ curl -X DELETE "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def12345 -H "Authorization: Bearer {access_token}" # Delete by FQN -curl -X DELETE "{base_url}/api/v1/dataContracts/name/sales-orders-contract?hardDelete=true" \ +curl -X DELETE "{base_url}/api/v1/dataContracts/name/sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract?hardDelete=true" \ -H "Authorization: Bearer {access_token}" # Restore soft-deleted contract diff --git a/v2.1.x-SNAPSHOT/api-reference/data-contracts/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-contracts/list.mdx index 88c4f2b0b..af34ed326 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-contracts/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-contracts/list.mdx @@ -49,13 +49,13 @@ configure( jwt_token="your-jwt-token" ) -# List all active contracts -contracts = DataContracts.list(params={"status": "Approved"}) -for c in contracts.data: - print(f"{c.fullyQualifiedName} ({c.entityStatus})") +# List approved contracts +contracts = DataContracts.list(filters={"status": "Approved"}) +for c in contracts.entities: + print(f"{c.fullyQualifiedName.root} ({c.entityStatus})") # List contracts for a specific entity -contracts = DataContracts.list(params={ +contracts = DataContracts.list(filters={ "entity": "a1b2c3d4-e5f6-7890-abcd-ef1234567890" }) ``` @@ -74,7 +74,7 @@ list().limit(20).fetch().forEach(contract -> { curl "{base_url}/api/v1/dataContracts?limit=10" \ -H "Authorization: Bearer {access_token}" -# List active contracts +# List approved contracts curl "{base_url}/api/v1/dataContracts?status=Approved&fields=owners" \ -H "Authorization: Bearer {access_token}" @@ -91,7 +91,7 @@ curl "{base_url}/api/v1/dataContracts?entity=a1b2c3d4-e5f6-7890-abcd-ef123456789 { "id": "f7a1b2c3-d4e5-6789-0abc-def123456789", "name": "sales-orders-contract", - "fullyQualifiedName": "sales-orders-contract", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "entityStatus": "Approved", "entity": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", diff --git a/v2.1.x-SNAPSHOT/api-reference/data-contracts/odcs.mdx b/v2.1.x-SNAPSHOT/api-reference/data-contracts/odcs.mdx index 3684190c6..f940e26dc 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-contracts/odcs.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-contracts/odcs.mdx @@ -61,16 +61,26 @@ yaml_str = DataContracts.export_odcs(contract_id).as_yaml().execute() print(yaml_str) # Export by FQN -odcs = DataContracts.export_odcs_by_name("sales-orders-contract").execute() +odcs = DataContracts.export_odcs_by_name("sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract").execute() ``` ```java Export ODCS -// Export using the REST client +import java.util.UUID; + +// client is an initialized OpenMetadataClient. +var contractId = UUID.fromString("f7a1b2c3-d4e5-6789-0abc-def123456789"); + +// Export as an ODCS object var odcs = client.dataContracts().exportToODCS(contractId); System.out.println("ODCS version: " + odcs.getApiVersion()); +System.out.println("Status: " + odcs.getStatus()); // Export as YAML String yaml = client.dataContracts().exportToODCSYaml(contractId); + +// Export by fully qualified name +var byName = client.dataContracts().exportToODCSByFqn( + "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract"); ``` ```bash Export ODCS @@ -84,7 +94,7 @@ curl "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/odcs/ -H "Accept: application/yaml" # Export by FQN -curl "{base_url}/api/v1/dataContracts/name/sales-orders-contract/odcs" \ +curl "{base_url}/api/v1/dataContracts/name/sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract/odcs" \ -H "Authorization: Bearer {access_token}" ``` @@ -196,7 +206,7 @@ curl "{base_url}/api/v1/dataContracts/name/sales-orders-contract/odcs" \ - Type of the entity (e.g., `table`, `topic`, `apiEndpoint`). + Type of the entity, for example `table`, `topic`, `apiEndpoint`. @@ -234,20 +244,43 @@ contract = (DataContracts.import_odcs(table_id, "table") ``` ```java Import ODCS -// Import from ODCS JSON -var contract = client.dataContracts().importFromODCS( - odcsContract, entityId, "table" -); - -// Import from YAML -var contract = client.dataContracts().importFromODCSYaml( - yamlContent, entityId, "table" -); - -// Import from YAML, keeping quality rules without creating test cases -var contract = client.dataContracts().importFromODCSYaml( - yamlContent, entityId, "table", false -); +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.UUID; +import org.openmetadata.schema.entity.data.DataContract; +import org.openmetadata.sdk.network.HttpMethod; +import org.openmetadata.sdk.network.RequestOptions; + +// client is an initialized OpenMetadataClient. +var entityId = UUID.fromString("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +String yamlContent = Files.readString(Path.of("contract.yaml")); + +// Import from an ODCS object (creates a new contract). +// odcsContract is an ODCSDataContract, for example one returned by exportToODCS. +var imported = client.dataContracts().importFromODCS(odcsContract, entityId, "table"); + +// Import from YAML (creates a new contract) +var importedFromYaml = client.dataContracts().importFromODCSYaml( + yamlContent, entityId, "table"); + +// Update an existing contract from YAML with smart merge +var merged = client.dataContracts().createOrUpdateFromODCSYaml( + yamlContent, entityId, "table"); + +// Replace an existing contract from YAML +var replaced = client.dataContracts().createOrUpdateFromODCSYaml( + yamlContent, entityId, "table", "replace"); + +// Import from YAML, keeping quality rules without creating test cases. +// The SDK method has no createTestCases option, so call the endpoint directly. +var options = RequestOptions.builder() + .queryParam("entityId", entityId.toString()) + .queryParam("entityType", "table") + .queryParam("createTestCases", "false") + .header("Content-Type", "application/yaml") + .build(); +var withoutTestCases = client.getHttpClient().execute( + HttpMethod.POST, "/v1/dataContracts/odcs/yaml", yamlContent, DataContract.class, options); ``` ```bash Import ODCS @@ -368,11 +401,32 @@ curl -X POST "{base_url}/api/v1/dataContracts/odcs/validate/yaml?entityId=a1b2c3 ``` ```java Validate YAML -ContractValidation validation = client.dataContracts().validateODCSYaml( - yamlContent, entityId, "table", true -); -ODCSImportReport report = validation.getOdcsImportReport(); -System.out.println("Can import: " + report.getCanImport()); +import com.fasterxml.jackson.databind.ObjectMapper; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.UUID; +import org.openmetadata.sdk.network.HttpMethod; +import org.openmetadata.sdk.network.RequestOptions; + +// client is an initialized OpenMetadataClient. +var entityId = UUID.fromString("a1b2c3d4-e5f6-7890-abcd-ef1234567890"); +String yamlContent = Files.readString(Path.of("contract.yaml")); + +var validation = client.dataContracts().validateODCSYaml(yamlContent, entityId, "table"); +System.out.println("Valid: " + validation.getValid()); + +// The SDK model has no createTestCases option or import report, +// so call the endpoint directly to read the report. +var options = RequestOptions.builder() + .queryParam("entityId", entityId.toString()) + .queryParam("entityType", "table") + .queryParam("createTestCases", "true") + .header("Content-Type", "application/yaml") + .build(); +String response = client.getHttpClient().executeForString( + HttpMethod.POST, "/v1/dataContracts/odcs/validate/yaml", yamlContent, options); +var report = new ObjectMapper().readTree(response).path("odcsImportReport"); +System.out.println("Can import: " + report.path("canImport").asBoolean()); ``` ```json Response diff --git a/v2.1.x-SNAPSHOT/api-reference/data-contracts/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-contracts/retrieve.mdx index 31b1b0565..03f365513 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-contracts/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-contracts/retrieve.mdx @@ -36,7 +36,7 @@ Use `GET /v1/dataContracts/entity` to get the effective contract for an entity, - Type of the entity (e.g., `table`, `topic`, `dashboard`). + Type of the entity, for example `table`, `topic`, `dashboard`. @@ -54,17 +54,17 @@ configure( ) # Get by ID -contract = DataContracts.get("f7a1b2c3-d4e5-6789-0abc-def123456789") -print(f"{contract.name}: {contract.entityStatus}") +contract = DataContracts.retrieve("f7a1b2c3-d4e5-6789-0abc-def123456789") +print(f"{contract.name.root}: {contract.entityStatus}") # Get by FQN -contract = DataContracts.get_by_name("sales-orders-contract") +contract = DataContracts.retrieve_by_name("sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract") # Get effective contract for an entity (includes inherited properties) -contract = DataContracts.get(params={ - "entityId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "entityType": "table" -}) +contract = DataContracts.get_by_entity( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + "table" +) ``` ```java GET /v1/dataContracts/{id} @@ -77,7 +77,7 @@ FluentDataContract contract = find(contractId) System.out.println(contract.getFqn()); // Get by FQN -FluentDataContract contract = findByName("sales-orders-contract") +FluentDataContract contract = findByName("sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract") .includeAll() .fetch(); @@ -92,7 +92,7 @@ curl "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789?field -H "Authorization: Bearer {access_token}" # Get by FQN -curl "{base_url}/api/v1/dataContracts/name/sales-orders-contract" \ +curl "{base_url}/api/v1/dataContracts/name/sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract" \ -H "Authorization: Bearer {access_token}" # Get effective contract for an entity (includes inherited) @@ -177,7 +177,7 @@ curl "{base_url}/api/v1/dataContracts/entity?entityId=a1b2c3d4-e5f6-7890-abcd-ef - SLA expectations (refresh frequency, latency, availability). + SLA expectations (refresh frequency, maximum latency, availability time, time zone, and retention). diff --git a/v2.1.x-SNAPSHOT/api-reference/data-contracts/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-contracts/update.mdx index 74eb84740..cf5b26c2e 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-contracts/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-contracts/update.mdx @@ -76,7 +76,7 @@ curl -X PATCH "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456 { "id": "f7a1b2c3-d4e5-6789-0abc-def123456789", "name": "sales-orders-contract", - "fullyQualifiedName": "sales-orders-contract", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "description": "Updated contract for sales orders table", "entityStatus": "Approved", "entity": { diff --git a/v2.1.x-SNAPSHOT/api-reference/data-contracts/validate.mdx b/v2.1.x-SNAPSHOT/api-reference/data-contracts/validate.mdx index d1ad71766..97c2888a4 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-contracts/validate.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-contracts/validate.mdx @@ -32,35 +32,35 @@ Validate the effective contract for a specific entity, including rules inherited - Type of the entity (e.g., `table`, `topic`). + Type of the entity, for example `table`, `topic`. ```python POST /v1/dataContracts/{id}/validate -from metadata.sdk import configure, get_client +from metadata.sdk import client, configure from metadata.sdk.entities import DataContracts configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Validate a specific contract -result = client.post( - f"/dataContracts/{contract_id}/validate" -) +result = rest.post("/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/validate") print(f"Status: {result['contractExecutionStatus']}") # Validate by entity -result = client.post("/dataContracts/entity/validate", params={ - "entityId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", - "entityType": "table" -}) +result = DataContracts.validate_by_entity( + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + "table" +) +print(f"Status: {result.contractExecutionStatus}") ``` ```java POST /v1/dataContracts/{id}/validate import static org.openmetadata.sdk.fluent.DataContracts.*; +import org.openmetadata.schema.entity.datacontract.DataContractResult; // Validate a contract DataContractResult result = forContract(contractId).validate(); @@ -68,7 +68,7 @@ System.out.println("Status: " + result.getContractExecutionStatus()); // Or from a loaded contract FluentDataContract contract = find(contractId).fetch(); -DataContractResult result = contract.validate(); +DataContractResult sameResult = contract.validate(); ``` ```bash POST /v1/dataContracts/{id}/validate @@ -86,7 +86,7 @@ curl -X POST "{base_url}/api/v1/dataContracts/entity/validate?entityId=a1b2c3d4- ```json Response (Validation Result) { "id": "e1f2a3b4-c5d6-7890-ef12-345678901234", - "dataContractFQN": "sales-orders-contract", + "dataContractFQN": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "timestamp": 1769986400000, "contractExecutionStatus": "Success", "schemaValidation": { @@ -163,6 +163,10 @@ Programmatically add a validation result (useful for external validation pipelin ### Body Parameters + + Fully qualified name of the data contract the result belongs to. + + Epoch timestamp (milliseconds) of the validation run. @@ -224,16 +228,17 @@ Programmatically add a validation result (useful for external validation pipelin ```python Add Result -from metadata.sdk import configure, get_client +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Add a validation result -client.put(f"/dataContracts/{contract_id}/results", json={ +rest.put("/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/results", json={ + "dataContractFQN": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "timestamp": 1769986400000, "contractExecutionStatus": "Success", "schemaValidation": {"passed": 4, "failed": 0, "total": 4}, @@ -259,6 +264,7 @@ curl -X PUT "{base_url}/api/v1/dataContracts/f7a1b2c3-d4e5-6789-0abc-def12345678 -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ + "dataContractFQN": "sample_data.ecommerce_db.shopify.sales_orders.dataContract_sales-orders-contract", "timestamp": 1769986400000, "contractExecutionStatus": "Success", "schemaValidation": {"passed": 4, "failed": 0, "total": 4, "failedFields": []}, diff --git a/v2.1.x-SNAPSHOT/api-reference/data-contracts/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-contracts/versions.mdx index b1c46cbc7..f8917e3b1 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-contracts/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-contracts/versions.mdx @@ -20,32 +20,37 @@ Every change to a data contract creates a new version. Use the versions API to l Use `GET /v1/dataContracts/{id}/versions/{version}` to retrieve a specific version. - Version number in `major.minor` format (e.g., `0.1`, `0.2`, `1.0`). + Version number in `major.minor` format, for example `0.1`, `0.2`, `1.0`. ```python GET /v1/dataContracts/{id}/versions -from metadata.sdk import configure +import json + +from metadata.sdk import client, configure from metadata.sdk.entities import DataContracts configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) +rest = client().ometa.client # List all versions -versions = DataContracts.list_versions("f7a1b2c3-d4e5-6789-0abc-def123456789") -for v in versions: - print(f"v{v.version}: {v.updatedBy} at {v.updatedAt}") +history = rest.get("/dataContracts/f7a1b2c3-d4e5-6789-0abc-def123456789/versions") +for item in history["versions"]: + v = json.loads(item) + print(f"v{v['version']}: {v['updatedBy']} at {v['updatedAt']}") # Get specific version -contract_v1 = DataContracts.get_version( +contract_v1 = DataContracts.get_specific_version( "f7a1b2c3-d4e5-6789-0abc-def123456789", "0.1" ) ``` ```java GET /v1/dataContracts/{id}/versions +// client is an initialized OpenMetadataClient. // List versions using the client var history = client.dataContracts().listVersions(contractId); for (var version : history.getVersions()) { diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/create.mdx index 393f162f1..b800da984 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/create.mdx @@ -113,13 +113,13 @@ request = CreateTestCaseRequest( ) test_case = TestCases.create(request) -print(f"Created: {test_case.fullyQualifiedName}") +print(f"Created: {test_case.fullyQualifiedName.root}") ``` ```java POST /v1/dataQuality/testCases import org.openmetadata.sdk.fluent.builders.TestCaseBuilder; -// Use an initialized OpenMetadataClient named client. +// client is an initialized OpenMetadataClient. var testCase = TestCaseBuilder.create(client) .name("column_value_max_to_be_between") .testDefinition("columnValueMaxToBeBetween") diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/delete.mdx index 6573e1f6b..c63f62160 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/delete.mdx @@ -67,27 +67,34 @@ TestCases.delete( ) # Delete by name -TestCases.delete_by_name( - "sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between" +test_case = TestCases.retrieve_by_name( + "sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between", + fields=["testDefinition", "testSuite"] ) +TestCases.delete(test_case.id) # Restore a soft-deleted test case TestCases.restore("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") ``` ```java DELETE /v1/dataQuality/testCases/{id} -import static org.openmetadata.sdk.fluent.TestCases.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "c1bce355-fa2f-48c6-ab4d-fad722a56ed7"; // Soft delete -TestCases.delete("c1bce355-fa2f-48c6-ab4d-fad722a56ed7").execute(); +client.testCases().delete(id); + +// Restore +client.testCases().restore(id); // Hard delete -TestCases.delete("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") - .hardDelete() - .execute(); +client.testCases().delete(id, Map.of("hardDelete", "true")); -// Restore -TestCases.restore("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); +// Delete by name: look up the ID first +var testCase = client.testCases().getByName("sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between"); +client.testCases().delete(testCase.getId().toString()); ``` ```bash DELETE /v1/dataQuality/testCases/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/list.mdx index 8d9e575bb..d61343830 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/list.mdx @@ -73,50 +73,52 @@ configure( ) # List first page -cases = TestCases.list(limit=50) -for tc in cases.data: - print(f"{tc.fullyQualifiedName}") +cases = TestCases.list(fields=["testDefinition", "testSuite"], limit=50) +for tc in cases.entities: + print(f"{tc.fullyQualifiedName.root}") # List all with auto-pagination -for tc in TestCases.list_all(): - print(f"{tc.name}: {tc.entityLink}") +for tc in TestCases.list_all(fields=["testDefinition", "testSuite"]): + print(f"{tc.name.root}: {tc.entityLink.root}") # Filter by test suite cases = TestCases.list( - testSuiteId="e86a9a11-852f-4bac-b5a7-993b2bbbb572", - fields=["owners", "testDefinition", "testCaseResult"], + filters={"testSuiteId": "e86a9a11-852f-4bac-b5a7-993b2bbbb572"}, + fields=["owners", "testDefinition", "testSuite", "testCaseResult"], limit=50 ) -for tc in cases.data: - print(f"{tc.name} - {tc.testDefinition.name}") +for tc in cases.entities: + print(f"{tc.name.root} - {tc.testDefinition.name}") # Filter by entity link cases = TestCases.list( - entityLink="<#E::table::sample_data.ecommerce_db.shopify.dim_address>", - fields=["testCaseResult"], + filters={"entityLink": "<#E::table::sample_data.ecommerce_db.shopify.dim_address>"}, + fields=["testDefinition", "testSuite", "testCaseResult"], limit=50 ) ``` ```java GET /v1/dataQuality/testCases -import static org.openmetadata.sdk.fluent.TestCases.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = TestCases.list() - .limit(50) - .execute(); - -for (var tc : result.getData()) { - System.out.println(tc.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.testCases().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } -// Filter by test suite -var result = TestCases.list() - .testSuiteId("e86a9a11-852f-4bac-b5a7-993b2bbbb572") - .fields("owners", "testDefinition", "testCaseResult") - .limit(50) - .execute(); +// Filter by test suite with fields +var filtered = new ListParams() + .addFilter("testSuiteId", "e86a9a11-852f-4bac-b5a7-993b2bbbb572") + .setFields("testCaseResult,testDefinition") + .setLimit(50); +var filteredPage = client.testCases().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/dataQuality/testCases diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/retrieve.mdx index e73bf1ca2..de5188777 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/retrieve.mdx @@ -28,7 +28,7 @@ Get a single test case by its unique ID or fully qualified name. Use `GET /v1/dataQuality/testCases/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the test case (e.g., `sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between`). + Fully qualified name of the test case, for example `sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between`. @@ -51,7 +51,7 @@ configure( # Get by ID tc = TestCases.retrieve("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") -print(f"{tc.fullyQualifiedName}: {tc.entityLink}") +print(f"{tc.fullyQualifiedName.root}: {tc.entityLink.root}") # Get by ID with fields tc = TestCases.retrieve( @@ -72,16 +72,21 @@ tc = TestCases.retrieve_by_name( ``` ```java GET /v1/dataQuality/testCases/{id} -import static org.openmetadata.sdk.fluent.TestCases.*; +// client is an initialized OpenMetadataClient. +var testCase = client.testCases().get("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); -// Get by ID -var tc = TestCases.retrieve("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); +// Get by ID with fields +var testCaseWithFields = client.testCases().get( + "c1bce355-fa2f-48c6-ab4d-fad722a56ed7", + "testCaseResult,testDefinition"); + +// Get by fully qualified name +var testCaseByName = client.testCases().getByName("sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between"); // Get by name with fields -var tc = TestCases.retrieveByName( +var testCaseByNameWithFields = client.testCases().getByName( "sample_data.ecommerce_db.shopify.dim_address.shop_id.column_value_max_to_be_between", - "testCaseResult,testDefinition" -); + "testCaseResult,testDefinition"); ``` ```bash GET /v1/dataQuality/testCases/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/update.mdx index a0f3190ce..c85b5b34f 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/update.mdx @@ -54,7 +54,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -78,15 +78,16 @@ tc.parameterValues = [ ] updated = TestCases.update(tc) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dataQuality/testCases/{id} -import static org.openmetadata.sdk.fluent.TestCases.*; +// client is an initialized OpenMetadataClient. +var testCaseId = "c1bce355-fa2f-48c6-ab4d-fad722a56ed7"; +var testCase = client.testCases().get(testCaseId); +testCase.setDescription("Updated: Validates shop_id max value stays between 1 and 200"); -var tc = TestCases.retrieve("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); -tc.setDescription("Updated: Validates shop_id max value stays between 1 and 200"); -var updated = TestCases.update(tc); +var updated = client.testCases().update(testCaseId, testCase); ``` ```bash PATCH /v1/dataQuality/testCases/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/versions.mdx index 07c9db125..057c94282 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-cases/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dataQuality/testCases/{id}/versions/{version}` to retrieve a specif - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dataQuality/testCases/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import TestCases @@ -40,7 +42,8 @@ configure( # List all versions versions = TestCases.get_versions("c1bce355-fa2f-48c6-ab4d-fad722a56ed7") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version tc_v1 = TestCases.get_specific_version( @@ -51,20 +54,18 @@ print(f"Original params: {tc_v1.parameterValues}") ``` ```java GET /v1/dataQuality/testCases/{id}/versions -import static org.openmetadata.sdk.fluent.TestCases.*; +// client is an initialized OpenMetadataClient. +var id = "c1bce355-fa2f-48c6-ab4d-fad722a56ed7"; // List all versions -var history = TestCases.getVersions("c1bce355-fa2f-48c6-ab4d-fad722a56ed7"); - +var history = client.testCases().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = TestCases.getSpecificVersion( - "c1bce355-fa2f-48c6-ab4d-fad722a56ed7", - 0.1 -); +var v1 = client.testCases().getVersion(id, 0.1); +System.out.println(v1.getDescription()); ``` ```bash GET /v1/dataQuality/testCases/{id}/versions diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/create.mdx index 2b756ea99..c792908fa 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/create.mdx @@ -32,7 +32,7 @@ Create a custom test definition to define organization-specific data quality val - Array of data types this test can be applied to (e.g., `STRING`, `INT`, `DOUBLE`, `VARCHAR`, `CHAR`, `TEXT`, `NUMBER`, `FLOAT`, `BOOLEAN`). Only applicable when `entityType` is `COLUMN`. + Array of data types this test can be applied to, for example `STRING`, `INT`, `DOUBLE`, `VARCHAR`, `CHAR`, `TEXT`, `NUMBER`, `FLOAT`, `BOOLEAN`. Only applicable when `entityType` is `COLUMN`. @@ -44,7 +44,7 @@ Create a custom test definition to define organization-specific data quality val - Data type of the parameter (e.g., `INT`, `STRING`, `BOOLEAN`, `ARRAY`, `TABLE`). + Data type of the parameter, for example `INT`, `STRING`, `BOOLEAN`, `ARRAY`, `TABLE`. @@ -92,7 +92,7 @@ Create a custom test definition to define organization-specific data quality val - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -136,21 +136,40 @@ request = CreateTestDefinitionRequest( ) test_def = TestDefinitions.create(request) -print(f"Created: {test_def.name}") +print(f"Created: {test_def.name.root}") ``` ```java POST /v1/dataQuality/testDefinitions -import static org.openmetadata.sdk.fluent.TestDefinitions.*; import java.util.List; - -var testDef = TestDefinitions.builder() - .name("columnValuesToMatchBusinessRule") - .displayName("Column Values To Match Business Rule") - .description("Validates that column values conform to a custom business rule regex pattern") - .entityType("COLUMN") - .testPlatforms(List.of("OpenMetadata")) - .supportedDataTypes(List.of("STRING", "VARCHAR", "TEXT")) - .create(); +import org.openmetadata.schema.api.tests.CreateTestDefinition; +import org.openmetadata.schema.tests.TestCaseParameter; +import org.openmetadata.schema.tests.TestPlatform; +import org.openmetadata.schema.type.ColumnDataType; +import org.openmetadata.schema.type.TestCaseParameterDataType; +import org.openmetadata.schema.type.TestDefinitionEntityType; + +// client is an initialized OpenMetadataClient. +var request = new CreateTestDefinition() + .withName("columnValuesToMatchBusinessRule") + .withDisplayName("Column Values To Match Business Rule") + .withDescription("Validates that column values conform to a custom business rule regex pattern") + .withEntityType(TestDefinitionEntityType.COLUMN) + .withTestPlatforms(List.of(TestPlatform.OPEN_METADATA)) + .withSupportedDataTypes(List.of( + ColumnDataType.STRING, ColumnDataType.VARCHAR, ColumnDataType.TEXT)) + .withParameterDefinition(List.of( + new TestCaseParameter() + .withName("regexPattern") + .withDataType(TestCaseParameterDataType.STRING) + .withRequired(true) + .withDescription("The regex pattern to match against"), + new TestCaseParameter() + .withName("threshold") + .withDataType(TestCaseParameterDataType.INT) + .withRequired(false) + .withDescription("Maximum number of non-matching values allowed"))); + +var testDefinition = client.testDefinitions().create(request); ``` ```bash POST /v1/dataQuality/testDefinitions diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/list.mdx index e25f6995f..b93f3888c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/list.mdx @@ -32,7 +32,7 @@ List all test definitions with optional filtering and pagination. - Filter by test platform (e.g., `OpenMetadata`). + Filter by test platform, for example `OpenMetadata`. @@ -40,7 +40,7 @@ List all test definitions with optional filtering and pagination. - Filter by supported data type (e.g., `STRING`, `INT`, `DOUBLE`). + Filter by supported data type, for example `STRING`, `INT`, `DOUBLE`. @@ -55,41 +55,43 @@ configure( # List first page definitions = TestDefinitions.list(limit=50) -for td in definitions.data: - print(f"{td.name} ({td.entityType})") +for td in definitions.entities: + print(f"{td.name.root} ({td.entityType.value})") # List all with auto-pagination for td in TestDefinitions.list_all(): - print(f"{td.name}: {td.description}") + print(f"{td.name.root}: {td.description.root}") # Filter by entity type column_defs = TestDefinitions.list( - entityType="COLUMN", + filters={"entityType": "COLUMN"}, fields=["owners"], limit=50 ) -for td in column_defs.data: - print(f"{td.name} - supports: {td.supportedDataTypes}") +for td in column_defs.entities: + print(f"{td.name.root} - supports: {td.supportedDataTypes}") ``` ```java GET /v1/dataQuality/testDefinitions -import static org.openmetadata.sdk.fluent.TestDefinitions.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = TestDefinitions.list() - .limit(50) - .execute(); - -for (var td : result.getData()) { - System.out.println(td.getName() + " (" + td.getEntityType() + ")"); +var params = new ListParams().setLimit(50); +var page = client.testDefinitions().list(params); +for (var item : page.getData()) { + System.out.println(item.getName()); } // Filter by entity type -var result = TestDefinitions.list() - .entityType("COLUMN") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("entityType", "COLUMN") + .setLimit(50); +var filteredPage = client.testDefinitions().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getName()); +} ``` ```bash GET /v1/dataQuality/testDefinitions @@ -186,7 +188,7 @@ Returns a paginated list of test definition objects. Use the `fields` parameter - Supported test platforms (e.g., `OpenMetadata`). + Supported test platforms, for example `OpenMetadata`. @@ -202,7 +204,7 @@ Returns a paginated list of test definition objects. Use the `fields` parameter - Data type of the parameter (e.g., `INT`, `STRING`, `BOOLEAN`). + Data type of the parameter, for example `INT`, `STRING`, `BOOLEAN`. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/retrieve.mdx index 47c77ff3b..02acfc373 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-definitions/retrieve.mdx @@ -16,7 +16,7 @@ Get a single test definition by its unique ID or name. - Comma-separated list of fields to include (e.g., `owners`). + Comma-separated list of fields to include, for example `owners`. @@ -28,7 +28,7 @@ Get a single test definition by its unique ID or name. Use `GET /v1/dataQuality/testDefinitions/name/{name}` to retrieve by name. - Name of the test definition (e.g., `columnValueLengthsToBeBetween`). + Name of the test definition, for example `columnValueLengthsToBeBetween`. @@ -51,7 +51,7 @@ configure( # Get by ID td = TestDefinitions.retrieve("a636d153-f1e8-45be-86d3-52aa6b71730d") -print(f"{td.name}: {td.description}") +print(f"{td.name.root}: {getattr(td.description, 'root', td.description)}") # Get by ID with fields td = TestDefinitions.retrieve( @@ -66,13 +66,11 @@ print(f"Parameters: {[p.name for p in td.parameterDefinition]}") ``` ```java GET /v1/dataQuality/testDefinitions/{id} -import static org.openmetadata.sdk.fluent.TestDefinitions.*; +// client is an initialized OpenMetadataClient. +var testDefinition = client.testDefinitions().get("a636d153-f1e8-45be-86d3-52aa6b71730d"); -// Get by ID -var td = TestDefinitions.retrieve("a636d153-f1e8-45be-86d3-52aa6b71730d"); - -// Get by name -var td = TestDefinitions.retrieveByName("columnValueLengthsToBeBetween"); +// Get by fully qualified name +var testDefinitionByName = client.testDefinitions().getByName("columnValueLengthsToBeBetween"); ``` ```bash GET /v1/dataQuality/testDefinitions/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/create.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/create.mdx index 947d3dc0e..27e76cf08 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/create.mdx @@ -66,12 +66,14 @@ request = CreateTestSuiteRequest( ) test_suite = TestSuites.create(request) -print(f"Created: {test_suite.name}") +print(f"Created: {test_suite.name.root}") ``` ```java POST /v1/dataQuality/testSuites import org.openmetadata.sdk.fluent.builders.TestSuiteBuilder; +// client is an initialized OpenMetadataClient. + // Create a logical test suite // Use an initialized OpenMetadataClient named client. var testSuite = new TestSuiteBuilder(client) diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/delete.mdx index ab805609b..c46c667a0 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/delete.mdx @@ -67,25 +67,30 @@ TestSuites.delete( ) # Delete by name -TestSuites.delete_by_name("b5fcae09-02c2-4c0b-8c4a-5b52d650e592") +TestSuites.delete(TestSuites.retrieve_by_name("sample_data.ecommerce_db.shopify.dim_address.testSuite").id) # Restore a soft-deleted test suite TestSuites.restore("e86a9a11-852f-4bac-b5a7-993b2bbbb572") ``` ```java DELETE /v1/dataQuality/testSuites/{id} -import static org.openmetadata.sdk.fluent.TestSuites.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "e86a9a11-852f-4bac-b5a7-993b2bbbb572"; // Soft delete -TestSuites.delete("e86a9a11-852f-4bac-b5a7-993b2bbbb572").execute(); +client.testSuites().delete(id); + +// Restore +client.testSuites().restore(id); // Hard delete -TestSuites.delete("e86a9a11-852f-4bac-b5a7-993b2bbbb572") - .hardDelete() - .execute(); +client.testSuites().delete(id, Map.of("hardDelete", "true")); -// Restore -TestSuites.restore("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); +// Delete by name: look up the ID first +var testSuite = client.testSuites().getByName("sample_data.ecommerce_db.shopify.dim_address.testSuite"); +client.testSuites().delete(testSuite.getId().toString()); ``` ```bash DELETE /v1/dataQuality/testSuites/{id} @@ -98,7 +103,7 @@ curl -X DELETE "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7 -H "Authorization: Bearer {access_token}" # Delete by name -curl -X DELETE "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52d650e592" \ +curl -X DELETE "{base_url}/api/v1/dataQuality/testSuites/name/sample_data.ecommerce_db.shopify.dim_address.testSuite" \ -H "Authorization: Bearer {access_token}" # Restore soft-deleted test suite @@ -113,15 +118,15 @@ curl -X PUT "{base_url}/api/v1/dataQuality/testSuites/restore" \ ```json Response (Soft Delete) { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "version": 0.2, "updatedAt": 1769982800000, "updatedBy": "admin", "deleted": true, "owners": [], - "executable": true + "basic": true } ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/list.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/list.mdx index 4e2742e3d..37e60d98a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/list.mdx @@ -32,7 +32,7 @@ List all test suites with optional filtering and pagination. - Filter by test suite type: `executable` or `logical`. + Filter by test suite type, for example `logical`. The older value `executable` is still accepted. @@ -47,42 +47,44 @@ configure( # List first page suites = TestSuites.list(limit=50) -for ts in suites.data: - print(f"{ts.displayName} (executable: {ts.executable})") +for ts in suites.entities: + print(f"{ts.displayName} (basic: {ts.basic})") # List all with auto-pagination for ts in TestSuites.list_all(): - print(f"{ts.fullyQualifiedName}") + print(f"{ts.fullyQualifiedName.root}") # Filter by type logical_suites = TestSuites.list( - testSuiteType="logical", + filters={"testSuiteType": "logical"}, fields=["owners", "tests"], limit=50 ) -for ts in logical_suites.data: +for ts in logical_suites.entities: print(f"{ts.displayName}") ``` ```java GET /v1/dataQuality/testSuites -import static org.openmetadata.sdk.fluent.TestSuites.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = TestSuites.list() - .limit(50) - .execute(); - -for (var ts : result.getData()) { - System.out.println(ts.getDisplayName()); +var params = new ListParams().setLimit(50); +var page = client.testSuites().list(params); +for (var item : page.getData()) { + System.out.println(item.getDisplayName()); } -// Filter by type -var result = TestSuites.list() - .testSuiteType("logical") - .fields("owners", "tests") - .limit(50) - .execute(); +// Filter by type with fields +var filtered = new ListParams() + .addFilter("testSuiteType", "logical") + .setFields("owners,tests") + .setLimit(50); +var filteredPage = client.testSuites().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getDisplayName()); +} ``` ```bash GET /v1/dataQuality/testSuites @@ -91,7 +93,7 @@ curl "{base_url}/api/v1/dataQuality/testSuites?limit=50" \ -H "Authorization: Bearer {access_token}" # Filter by type -curl "{base_url}/api/v1/dataQuality/testSuites?testSuiteType=executable&limit=50" \ +curl "{base_url}/api/v1/dataQuality/testSuites?testSuiteType=logical&limit=50" \ -H "Authorization: Bearer {access_token}" # With fields @@ -106,15 +108,15 @@ curl "{base_url}/api/v1/dataQuality/testSuites?fields=owners,tests&limit=50" \ "data": [ { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "version": 0.1, "updatedAt": 1769982757893, "updatedBy": "admin", "deleted": false, "owners": [], - "executable": true + "basic": true } ], "paging": { @@ -153,8 +155,8 @@ Returns a paginated list of test suite objects. Use the `fields` parameter to re Human-readable display name. - - Whether this is an executable or logical test suite. + + `true` for a table-level (basic) test suite, `false` for a logical test suite. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/retrieve.mdx index f57b6d414..f906e54ae 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/retrieve.mdx @@ -51,7 +51,7 @@ configure( # Get by ID ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572") -print(f"{ts.displayName} (executable: {ts.executable})") +print(f"{ts.displayName} (basic: {ts.basic})") # Get by ID with fields ts = TestSuites.retrieve( @@ -60,20 +60,25 @@ ts = TestSuites.retrieve( ) # Get by fully qualified name -ts = TestSuites.retrieve_by_name("b5fcae09-02c2-4c0b-8c4a-5b52d650e592") +ts = TestSuites.retrieve_by_name("sample_data.ecommerce_db.shopify.dim_address.testSuite") ``` ```java GET /v1/dataQuality/testSuites/{id} -import static org.openmetadata.sdk.fluent.TestSuites.*; +// client is an initialized OpenMetadataClient. +var testSuite = client.testSuites().get("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); -// Get by ID -var ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); +// Get by ID with fields +var testSuiteWithFields = client.testSuites().get( + "e86a9a11-852f-4bac-b5a7-993b2bbbb572", + "owners,tests"); + +// Get by fully qualified name +var testSuiteByName = client.testSuites().getByName("sample_data.ecommerce_db.shopify.dim_address.testSuite"); // Get by name with fields -var ts = TestSuites.retrieveByName( - "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", - "owners,tests" -); +var testSuiteByNameWithFields = client.testSuites().getByName( + "sample_data.ecommerce_db.shopify.dim_address.testSuite", + "owners,tests"); ``` ```bash GET /v1/dataQuality/testSuites/{id} @@ -86,7 +91,7 @@ curl "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7-993b2bbbb -H "Authorization: Bearer {access_token}" # Get by name -curl "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52d650e592" \ +curl "{base_url}/api/v1/dataQuality/testSuites/name/sample_data.ecommerce_db.shopify.dim_address.testSuite" \ -H "Authorization: Bearer {access_token}" ``` @@ -95,15 +100,15 @@ curl "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52 ```json Response { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "version": 0.1, "updatedAt": 1769982757893, "updatedBy": "admin", "deleted": false, "owners": [], - "executable": true + "basic": true } ``` @@ -136,8 +141,8 @@ Returns a test suite object with all requested fields populated. Description of the test suite. - - Whether this is an executable or logical test suite. + + `true` for a table-level (basic) test suite, `false` for a logical test suite. diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/update.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/update.mdx index 08ff81e81..ac37d5a1a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/update.mdx @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -64,16 +64,16 @@ ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572") ts.description = "Updated: Critical data quality checks for production tables" updated = TestSuites.update(ts) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dataQuality/testSuites/{id} -import static org.openmetadata.sdk.fluent.TestSuites.*; +// client is an initialized OpenMetadataClient. +var testSuiteId = "e86a9a11-852f-4bac-b5a7-993b2bbbb572"; +var testSuite = client.testSuites().get(testSuiteId); +testSuite.setDescription("Updated: Critical data quality checks for production tables"); -// Retrieve, modify, and update -var ts = TestSuites.retrieve("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); -ts.setDescription("Updated: Critical data quality checks for production tables"); -var updated = TestSuites.update(ts); +var updated = client.testSuites().update(testSuiteId, testSuite); ``` ```bash PATCH /v1/dataQuality/testSuites/{id} @@ -86,7 +86,7 @@ curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7- ]' # Update by name -curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b-8c4a-5b52d650e592" \ +curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/name/sample_data.ecommerce_db.shopify.dim_address.testSuite" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json-patch+json" \ -d '[ @@ -99,16 +99,16 @@ curl -X PATCH "{base_url}/api/v1/dataQuality/testSuites/name/b5fcae09-02c2-4c0b- ```json Response { "id": "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - "name": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "name": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "displayName": "Data Contract - dim_address_comprehensive_contract", - "fullyQualifiedName": "b5fcae09-02c2-4c0b-8c4a-5b52d650e592", + "fullyQualifiedName": "sample_data.ecommerce_db.shopify.dim_address.testSuite", "description": "Updated: Critical data quality checks for production tables", "version": 0.2, "updatedAt": 1769982800000, "updatedBy": "admin", "deleted": false, "owners": [], - "executable": true + "basic": true } ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/versions.mdx index 79e7b4dbf..6e5793a74 100644 --- a/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/data-quality/test-suites/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dataQuality/testSuites/{id}/versions/{version}` to retrieve a speci - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dataQuality/testSuites/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import TestSuites @@ -40,31 +42,30 @@ configure( # List all versions versions = TestSuites.get_versions("e86a9a11-852f-4bac-b5a7-993b2bbbb572") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version ts_v1 = TestSuites.get_specific_version( "e86a9a11-852f-4bac-b5a7-993b2bbbb572", "0.1" ) -print(f"Original description: {ts_v1.description}") +print(f"Original description: {getattr(ts_v1.description, 'root', ts_v1.description)}") ``` ```java GET /v1/dataQuality/testSuites/{id}/versions -import static org.openmetadata.sdk.fluent.TestSuites.*; +// client is an initialized OpenMetadataClient. +var id = "e86a9a11-852f-4bac-b5a7-993b2bbbb572"; // List all versions -var history = TestSuites.getVersions("e86a9a11-852f-4bac-b5a7-993b2bbbb572"); - +var history = client.testSuites().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = TestSuites.getSpecificVersion( - "e86a9a11-852f-4bac-b5a7-993b2bbbb572", - 0.1 -); +var v1 = client.testSuites().getVersion(id, 0.1); +System.out.println(v1.getDescription()); ``` ```bash GET /v1/dataQuality/testSuites/{id}/versions @@ -83,8 +84,8 @@ curl "{base_url}/api/v1/dataQuality/testSuites/e86a9a11-852f-4bac-b5a7-993b2bbbb { "entityType": "testSuite", "versions": [ - "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"b5fcae09-02c2-4c0b-8c4a-5b52d650e592\",\"version\":0.2,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"description\":\"Updated description\",\"executable\":true}", - "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"b5fcae09-02c2-4c0b-8c4a-5b52d650e592\",\"version\":0.1,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"executable\":true}" + "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"sample_data.ecommerce_db.shopify.dim_address.testSuite\",\"version\":0.2,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"description\":\"Updated description\",\"basic\":true}", + "{\"id\":\"e86a9a11-852f-4bac-b5a7-993b2bbbb572\",\"name\":\"sample_data.ecommerce_db.shopify.dim_address.testSuite\",\"version\":0.1,\"displayName\":\"Data Contract - dim_address_comprehensive_contract\",\"basic\":true}" ] } ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/discovery/field-query.mdx b/v2.1.x-SNAPSHOT/api-reference/discovery/field-query.mdx index 6c440f7ff..0c5990dd3 100644 --- a/v2.1.x-SNAPSHOT/api-reference/discovery/field-query.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/discovery/field-query.mdx @@ -33,31 +33,35 @@ Search for entities by matching a specific field to a given value. This is usefu ```python GET /v1/search/fieldQuery -from metadata.sdk import configure, get_client +from urllib.parse import urlencode + +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Find tables with a specific column name -response = client.get("/search/fieldQuery", params={ +params = urlencode({ "fieldName": "columns.name", "fieldValue": "shop_id", "index": "table_search_index" }) +response = rest.get(f"/search/fieldQuery?{params}") for hit in response["hits"]["hits"]: entity = hit["_source"] print(f"{entity['fullyQualifiedName']} (score: {hit['_score']})") # Find entities with a specific tag -response = client.get("/search/fieldQuery", params={ +params = urlencode({ "fieldName": "tags.tagFQN", "fieldValue": "PII.Sensitive", "index": "table_search_index" }) +response = rest.get(f"/search/fieldQuery?{params}") for hit in response["hits"]["hits"]: entity = hit["_source"] @@ -65,6 +69,7 @@ for hit in response["hits"]["hits"]: ``` ```java GET /v1/search/fieldQuery +// client is an initialized OpenMetadataClient. // Find tables with a specific column name var response = client.searchApi().fieldQuery( "columns.name", // fieldName @@ -205,7 +210,7 @@ Returns an Elasticsearch-style response containing entities where the specified | Field Path | Description | Applicable Indexes | |------------|-------------|-------------------| | `columns.name` | Column name within a table | `table_search_index` | -| `tags.tagFQN` | Fully qualified tag name (e.g., `PII.Sensitive`) | All indexes | +| `tags.tagFQN` | Fully qualified tag name, for example `PII.Sensitive` | All indexes | | `owners.name` | Owner username | All indexes | | `service.name` | Service name | All entity indexes | | `database.name` | Database name | `table_search_index` | diff --git a/v2.1.x-SNAPSHOT/api-reference/discovery/search.mdx b/v2.1.x-SNAPSHOT/api-reference/discovery/search.mdx index ba66c99ca..0a26d0060 100644 --- a/v2.1.x-SNAPSHOT/api-reference/discovery/search.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/discovery/search.mdx @@ -32,7 +32,7 @@ Full-text search across all entity types in the metadata catalog. Uses Elasticse - Field to sort by (e.g., `name`, `updatedAt`, `totalVotes`). + Field to sort by, for example `name`, `updatedAt`, `totalVotes`. @@ -65,21 +65,24 @@ Full-text search across all entity types in the metadata catalog. Uses Elasticse ```python GET /v1/search/query -from metadata.sdk import configure, get_client +from urllib.parse import urlencode + +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Search for tables matching "customer" -response = client.get("/search/query", params={ +params = urlencode({ "q": "customer", "index": "table_search_index", "from": 0, "size": 10 }) +response = rest.get(f"/search/query?{params}") for hit in response["hits"]["hits"]: entity = hit["_source"] @@ -87,6 +90,7 @@ for hit in response["hits"]["hits"]: ``` ```java GET /v1/search/query +// client is an initialized OpenMetadataClient. // Search using the OpenMetadata client var response = client.searchApi().searchEntities( "customer", // query @@ -207,7 +211,7 @@ Returns an Elasticsearch-style response containing matched entities ranked by re - Search index the result was found in (e.g., `table_search_index`). + Search index the result was found in, for example `table_search_index`. diff --git a/v2.1.x-SNAPSHOT/api-reference/errors.mdx b/v2.1.x-SNAPSHOT/api-reference/errors.mdx index 4356e8643..e2a6decea 100644 --- a/v2.1.x-SNAPSHOT/api-reference/errors.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/errors.mdx @@ -278,15 +278,14 @@ except Exception as e: ``` ```java JAVA SDK -import org.openmetadata.client.api.TablesApi; -import org.openmetadata.client.ApiException; +import org.openmetadata.sdk.exceptions.OpenMetadataException; -TablesApi tablesApi = client.buildClient(TablesApi.class); +// client is an initialized OpenMetadataClient. try { - Table table = tablesApi.getTableByFQN("prod.analytics.customers", null, null); -} catch (ApiException e) { - switch (e.getCode()) { + var table = client.tables().getByName("prod.analytics.customers"); +} catch (OpenMetadataException e) { + switch (e.getStatusCode()) { case 404: System.out.println("Table not found"); break; diff --git a/v2.1.x-SNAPSHOT/api-reference/getting-started.mdx b/v2.1.x-SNAPSHOT/api-reference/getting-started.mdx index bd9370015..7e12e2538 100644 --- a/v2.1.x-SNAPSHOT/api-reference/getting-started.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/getting-started.mdx @@ -9,10 +9,14 @@ import BotsTileAdminNote from '/snippets/deployment/bots-tile-admin-note.mdx' Get up and running with the OpenMetadata API and SDKs. This guide walks you through authentication, SDK installation, and making your first API call. + +Most Python examples in this API reference use SDK 2.0 (`metadata.sdk`). The Topics and ML model services pages use the original client, because SDK 2.0 has no class for them. The pages under the SDK section also show the original client. For more information, see [Which Python SDK Should I Use?](/v2.1.x-SNAPSHOT/api-reference/sdk/python/overview#which-python-sdk-should-i-use). + + ## Prerequisites - A OpenMetadata account (cloud or self-hosted instance) -- Your instance base URL (e.g., `https://your-company.open-metadata.org/api`) +- Your instance base URL, for example `https://your-company.open-metadata.org/api` - **Python 3.11+**, **Java 21+**, or **Go 1.19+** (depending on your SDK choice) @@ -81,23 +85,13 @@ Set up the connection to your OpenMetadata instance: ```python Python -from metadata.ingestion.ometa.ometa_api import OpenMetadata -from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( - OpenMetadataConnection, -) -from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( - OpenMetadataJWTClientConfig, -) +from metadata.sdk import configure -server_config = OpenMetadataConnection( - hostPort="https://your-company.open-metadata.org/api", - authProvider="openmetadata", - securityConfig=OpenMetadataJWTClientConfig( - jwtToken="your-jwt-token" - ), +# The host must end with /api +configure( + host="https://your-company.open-metadata.org/api", + jwt_token="your-jwt-token", ) - -metadata = OpenMetadata(server_config) ``` ```java Java @@ -115,15 +109,10 @@ OpenMetadataClient client = new OpenMetadataClient(config); ```go Go import ometa "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" -restConfig := ometa.NewRestConfig( +client := ometa.NewClient( "https://your-company.open-metadata.org", - "", // APIVersion - 0, // Retry -> defaults to 3 - 0, // RetryWait -> defaults to 30 seconds - nil, // RetryCodes -> defaults to [429, 504] - "your-jwt-token", + ometa.WithToken("your-jwt-token"), ) -client, err := ometa.NewRest(restConfig) ``` ```bash cURL @@ -141,40 +130,32 @@ List the tables in your catalog to verify everything is working: ```python Python -from metadata.generated.schema.entity.data.table import Table +from metadata.sdk import Tables -tables = metadata.list_all_entities(entity=Table) -for table in tables: - print(f"{table.fullyQualifiedName}: {table.description}") +for table in Tables.list_all(): + print(f"{table.fullyQualifiedName.root}: {getattr(table.description, 'root', table.description)}") ``` ```java Java -TablesApi tablesApi = client.buildClient(TablesApi.class); -TableList tables = tablesApi.listTables(null, 10, null, null, null); +import org.openmetadata.sdk.models.ListParams; -for (Table table : tables.getData()) { +// client is an initialized OpenMetadataClient. + +var tables = client.tables().list(new ListParams().setLimit(10)); + +for (var table : tables.getData()) { System.out.println(table.getFullyQualifiedName()); } ``` ```go Go -resp, err := rest.Get("tables", map[string]string{"limit": "10"}) -if err != nil { - log.Fatal(err) -} -defer resp.Body.Close() +ctx := context.Background() -var result struct { - Data []struct { - FullyQualifiedName string `json:"fullyQualifiedName"` - } `json:"data"` -} -if err := json.NewDecoder(resp.Body).Decode(&result); err != nil { - log.Fatal(err) -} - -for _, table := range result.Data { - fmt.Println(table.FullyQualifiedName) +for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(*table.FullyQualifiedName) } ``` @@ -224,7 +205,7 @@ from metadata.generated.schema.api.data.createTable import CreateTableRequest from metadata.generated.schema.entity.data.table import Column, DataType # Initialize the SDK -configure(host="https://your-company.open-metadata.org", jwt_token="your-jwt-token") +configure(host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token") # Create and persist the table table = Tables.create(CreateTableRequest( @@ -238,15 +219,15 @@ table = Tables.create(CreateTableRequest( ], )) -print(f"Created: {table.fullyQualifiedName}") +print(f"Created: {table.fullyQualifiedName.root}") ``` ```java Java -import org.openmetadata.sdk.client.OpenMetadataClient; -import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.schema.entity.data.Table; import org.openmetadata.sdk.fluent.builders.TableBuilder; import org.openmetadata.sdk.fluent.builders.ColumnBuilder; +// client is the OpenMetadataClient from the "Initialize Your Client" step. // Create and persist the table in one fluent chain Table table = new TableBuilder(client) .name("customers") diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/create.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/create.mdx index 706006bf0..a3855388f 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/create.mdx @@ -36,7 +36,7 @@ Create a new classification for organizing tags into categories. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -67,18 +67,19 @@ request = CreateClassificationRequest( ) classification = Classifications.create(request) -print(f"Created: {classification.fullyQualifiedName}") +print(f"Created: {classification.fullyQualifiedName.root}") ``` ```java POST /v1/classifications -import static org.openmetadata.sdk.fluent.Classifications.*; - -// Create using builder pattern -var classification = Classifications.builder() - .name("Certification") - .description("Certifying Data Asset will provide the users with a clear idea of...") - .mutuallyExclusive(true) - .create(); +import org.openmetadata.schema.api.classification.CreateClassification; + +// client is an initialized OpenMetadataClient. +var request = new CreateClassification() + .withName("Certification") + .withDescription("Certifying Data Asset will provide the users with a clear idea of...") + .withMutuallyExclusive(true); + +var classification = client.classifications().create(request); ``` ```bash POST /v1/classifications diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/delete.mdx index f1502e18d..662141382 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/delete.mdx @@ -28,7 +28,7 @@ Delete a classification by ID or fully qualified name. Supports soft delete (def Use `DELETE /v1/classifications/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the classification (e.g., `Certification`). + Fully qualified name of the classification, for example `Certification`. @@ -67,28 +67,30 @@ Classifications.delete( ) # Delete by name -Classifications.delete_by_name("Certification") +Classifications.delete(Classifications.retrieve_by_name("Certification").id) # Restore a soft-deleted classification Classifications.restore("06d90883-6be9-4f7e-9475-753f10a95e94") ``` ```java DELETE /v1/classifications/{id} -import static org.openmetadata.sdk.fluent.Classifications.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "06d90883-6be9-4f7e-9475-753f10a95e94"; // Soft delete -Classifications.delete("06d90883-6be9-4f7e-9475-753f10a95e94").execute(); +client.classifications().delete(id); -// Hard delete -Classifications.delete("06d90883-6be9-4f7e-9475-753f10a95e94") - .hardDelete() - .execute(); +// Restore +client.classifications().restore(id); -// Delete by name -Classifications.deleteByName("Certification").execute(); +// Hard delete +client.classifications().delete(id, Map.of("hardDelete", "true")); -// Restore -Classifications.restore("06d90883-6be9-4f7e-9475-753f10a95e94"); +// Delete by name: look up the ID first +var classification = client.classifications().getByName("Certification"); +client.classifications().delete(classification.getId().toString()); ``` ```bash DELETE /v1/classifications/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/list.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/list.mdx index 28e5770f3..43152296a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/list.mdx @@ -43,12 +43,12 @@ configure( # List first page classifications = Classifications.list(limit=50) -for c in classifications.data: - print(f"{c.fullyQualifiedName} (mutuallyExclusive: {c.mutuallyExclusive})") +for c in classifications.entities: + print(f"{c.fullyQualifiedName.root} (mutuallyExclusive: {c.mutuallyExclusive})") # List all with auto-pagination for c in Classifications.list_all(): - print(f"{c.fullyQualifiedName}") + print(f"{c.fullyQualifiedName.root}") # With fields classifications = Classifications.list( @@ -58,22 +58,24 @@ classifications = Classifications.list( ``` ```java GET /v1/classifications -import static org.openmetadata.sdk.fluent.Classifications.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Classifications.list() - .limit(50) - .execute(); - -for (var c : result.getData()) { - System.out.println(c.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.classifications().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // With fields -var result = Classifications.list() - .fields("owners") - .limit(50) - .execute(); +var filtered = new ListParams() + .setFields("owners") + .setLimit(50); +var filteredPage = client.classifications().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/classifications diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/retrieve.mdx index 75868f41c..e9e69d1a9 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/retrieve.mdx @@ -16,7 +16,7 @@ Get a single classification by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners`). + Comma-separated list of fields to include, for example `owners`. @@ -28,7 +28,7 @@ Get a single classification by its unique ID or fully qualified name. Use `GET /v1/classifications/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the classification (e.g., `Certification`). + Fully qualified name of the classification, for example `Certification`. @@ -51,7 +51,7 @@ configure( # Get by ID classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94") -print(f"{classification.fullyQualifiedName}: {classification.description}") +print(f"{classification.fullyQualifiedName.root}: {getattr(classification.description, 'root', classification.description)}") # Get by ID with fields classification = Classifications.retrieve( @@ -70,22 +70,21 @@ classification = Classifications.retrieve_by_name( ``` ```java GET /v1/classifications/{id} -import static org.openmetadata.sdk.fluent.Classifications.*; - -// Get by ID -var classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94"); +// client is an initialized OpenMetadataClient. +var classification = client.classifications().get("06d90883-6be9-4f7e-9475-753f10a95e94"); // Get by ID with fields -var classification = Classifications.retrieve( +var classificationWithFields = client.classifications().get( "06d90883-6be9-4f7e-9475-753f10a95e94", - "owners" -); + "owners"); // Get by fully qualified name -var classification = Classifications.retrieveByName("Certification"); +var classificationByName = client.classifications().getByName("Certification"); // Get by name with fields -var classification = Classifications.retrieveByName("Certification", "owners"); +var classificationByNameWithFields = client.classifications().getByName( + "Certification", + "owners"); ``` ```bash GET /v1/classifications/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/update.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/update.mdx index 98468f05b..870cb318b 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/update.mdx @@ -20,7 +20,7 @@ Update a classification's properties using JSON Merge Patch. You can update by I Use `PATCH /v1/classifications/name/{fqn}` to update by fully qualified name. - Fully qualified name of the classification (e.g., `Certification`). + Fully qualified name of the classification, for example `Certification`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,16 +68,16 @@ classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94" classification.description = "Updated: Classification for data asset certification levels" updated = Classifications.update(classification) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/classifications/{id} -import static org.openmetadata.sdk.fluent.Classifications.*; - -// Retrieve, modify, and update -var classification = Classifications.retrieve("06d90883-6be9-4f7e-9475-753f10a95e94"); +// client is an initialized OpenMetadataClient. +var classificationId = "06d90883-6be9-4f7e-9475-753f10a95e94"; +var classification = client.classifications().get(classificationId); classification.setDescription("Updated: Classification for data asset certification levels"); -var updated = Classifications.update(classification); + +var updated = client.classifications().update(classificationId, classification); ``` ```bash PATCH /v1/classifications/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/versions.mdx index d64423ddc..5ded3810d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/classifications/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/classifications/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/classifications/{id}/versions/{version}` to retrieve a specific ver - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/classifications/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Classifications @@ -40,31 +42,29 @@ configure( # List all versions versions = Classifications.get_versions("06d90883-6be9-4f7e-9475-753f10a95e94") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version classification_v1 = Classifications.get_specific_version( "06d90883-6be9-4f7e-9475-753f10a95e94", "0.1" ) -print(f"Original description: {classification_v1.description}") +print(f"Original description: {getattr(classification_v1.description, 'root', classification_v1.description)}") ``` ```java GET /v1/classifications/{id}/versions -import static org.openmetadata.sdk.fluent.Classifications.*; +// client is an initialized OpenMetadataClient. +var id = "06d90883-6be9-4f7e-9475-753f10a95e94"; // List all versions -var history = Classifications.getVersions("06d90883-6be9-4f7e-9475-753f10a95e94"); - +var history = client.classifications().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Classifications.getSpecificVersion( - "06d90883-6be9-4f7e-9475-753f10a95e94", - 0.1 -); +var v1 = client.classifications().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/create.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/create.mdx index e6d6b59a4..44124a47e 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/create.mdx @@ -12,11 +12,11 @@ Create a new data product within a domain. ## Body Parameters - Name of the data product. Must be unique within the parent domain. + Name of the data product. Must be unique across all data products. - - Fully qualified name of the parent domain (e.g., `Marketing`). + + Fully qualified names of the parent domains, for example `["Marketing"]`. @@ -36,7 +36,7 @@ Create a new data product within a domain. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -76,24 +76,26 @@ configure( request = { "name": "CustomerInsights", "displayName": "Customer Insights", - "domain": "Marketing", + "domains": ["Marketing"], "description": "Curated customer analytics data product" } data_product = DataProducts.create(request) -print(f"Created: {data_product.fullyQualifiedName}") +print(f"Created: {data_product.fullyQualifiedName.root}") ``` ```java POST /v1/dataProducts -import static org.openmetadata.sdk.fluent.DataProducts.*; - -// Create using builder pattern -var dataProduct = DataProducts.builder() - .name("CustomerInsights") - .displayName("Customer Insights") - .domain("Marketing") - .description("Curated customer analytics data product") - .create(); +import java.util.List; +import org.openmetadata.schema.api.domains.CreateDataProduct; + +// client is an initialized OpenMetadataClient. +var request = new CreateDataProduct() + .withName("CustomerInsights") + .withDisplayName("Customer Insights") + .withDomains(List.of("Marketing")) + .withDescription("Curated customer analytics data product"); + +var dataProduct = client.dataProducts().create(request); ``` ```bash POST /v1/dataProducts @@ -102,7 +104,7 @@ curl -X POST "{base_url}/api/v1/dataProducts" \ -H "Content-Type: application/json" \ -d '{ "name": "CustomerInsights", - "domain": "Marketing", + "domains": ["Marketing"], "description": "Curated customer analytics data product", "owners": [], "experts": [] @@ -115,20 +117,22 @@ curl -X POST "{base_url}/api/v1/dataProducts" \ { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Curated customer analytics data product", "version": 0.1, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -153,7 +157,7 @@ Returns the created data product object with all specified properties and system - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. @@ -164,8 +168,8 @@ Returns the created data product object with all specified properties and system Description of the data product in Markdown format. - - Reference to the parent domain. + + References to the parent domains. @@ -224,4 +228,4 @@ curl -X PUT "{base_url}/api/v1/dataProducts" \ | `400` | `BAD_REQUEST` | Invalid request body or missing required fields | | `401` | `UNAUTHORIZED` | Invalid or missing authentication token | | `403` | `FORBIDDEN` | User lacks permission to create data products | -| `409` | `ENTITY_ALREADY_EXISTS` | Data product with same name already exists in domain (POST only) | +| `409` | `ENTITY_ALREADY_EXISTS` | Data product with the same name already exists (POST only) | diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/delete.mdx index e69068056..eb414ec39 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/delete.mdx @@ -1,13 +1,13 @@ --- title: Delete a Data Product -description: Delete a data product by ID or name, with soft/hard delete options +description: Delete a data product by ID or name, permanently sidebarTitle: Delete a Data Product api: DELETE /v1/dataProducts/{id} --- # Delete a Data Product -Delete a data product by ID or fully qualified name. Supports soft delete (default), hard delete, and restore operations. +Delete a data product by ID or fully qualified name. Deleting a data product is permanent. A deleted data product can't be restored. ## Delete by ID @@ -20,7 +20,7 @@ Delete a data product by ID or fully qualified name. Supports soft delete (defau - Permanently delete the data product. If `false`, the data product is soft-deleted and can be restored. + Not needed. A deleted data product is always permanently deleted, with or without this option. ## Delete by Name @@ -28,7 +28,7 @@ Delete a data product by ID or fully qualified name. Supports soft delete (defau Use `DELETE /v1/dataProducts/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the data product (e.g., `Marketing.CustomerInsights`). + Fully qualified name of the data product, for example `CustomerInsights`. @@ -36,15 +36,7 @@ Use `DELETE /v1/dataProducts/name/{fqn}` to delete by fully qualified name. - Permanently delete the data product. - - -## Restore a Soft-Deleted Data Product - -Use `PUT /v1/dataProducts/restore` to restore a soft-deleted data product. - - - UUID of the soft-deleted data product to restore. + Not needed. A deleted data product is always permanently deleted, with or without this option. @@ -57,89 +49,53 @@ configure( jwt_token="your-jwt-token" ) -# Soft delete by ID +# Delete by ID DataProducts.delete("b1839f98-f046-5f35-bdef-20f9b3395cb2") -# Hard delete +# Delete by ID with options DataProducts.delete( "b1839f98-f046-5f35-bdef-20f9b3395cb2", hard_delete=True ) # Delete by name -DataProducts.delete_by_name("Marketing.CustomerInsights") - -# Restore a soft-deleted data product -DataProducts.restore("b1839f98-f046-5f35-bdef-20f9b3395cb2") +DataProducts.delete(DataProducts.retrieve_by_name("CustomerInsights").id) ``` ```java DELETE /v1/dataProducts/{id} -import static org.openmetadata.sdk.fluent.DataProducts.*; +import java.util.Map; -// Soft delete -DataProducts.delete("b1839f98-f046-5f35-bdef-20f9b3395cb2").execute(); +// client is an initialized OpenMetadataClient. +var id = "b1839f98-f046-5f35-bdef-20f9b3395cb2"; -// Hard delete -DataProducts.delete("b1839f98-f046-5f35-bdef-20f9b3395cb2") - .hardDelete() - .execute(); - -// Delete by name -DataProducts.deleteByName("Marketing.CustomerInsights").execute(); +// Delete (permanent) +client.dataProducts().delete(id); -// Restore -DataProducts.restore("b1839f98-f046-5f35-bdef-20f9b3395cb2"); +// Delete by name: look up the ID first +var dataProduct = client.dataProducts().getByName("CustomerInsights"); +client.dataProducts().delete(dataProduct.getId().toString()); ``` ```bash DELETE /v1/dataProducts/{id} -# Soft delete by ID +# Delete by ID curl -X DELETE "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2" \ -H "Authorization: Bearer {access_token}" -# Hard delete +# Delete with options curl -X DELETE "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2?hardDelete=true" \ -H "Authorization: Bearer {access_token}" # Delete by name -curl -X DELETE "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ +curl -X DELETE "{base_url}/api/v1/dataProducts/name/CustomerInsights" \ -H "Authorization: Bearer {access_token}" - -# Restore soft-deleted data product -curl -X PUT "{base_url}/api/v1/dataProducts/restore" \ - -H "Authorization: Bearer {access_token}" \ - -H "Content-Type: application/json" \ - -d '{"id": "b1839f98-f046-5f35-bdef-20f9b3395cb2"}' ``` - -```json Response (Soft Delete) -{ - "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", - "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", - "description": "Curated customer analytics data product", - "version": 0.2, - "updatedAt": 1769984330261, - "updatedBy": "admin", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing" - }, - "deleted": true, - "owners": [], - "experts": [] -} -``` - - --- ## Returns -Soft delete returns the data product object with `deleted: true`. Hard delete returns no content (204). Restore returns the restored data product object. +Returns `200` with no content. The data product is permanently deleted and can't be restored. --- diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/list.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/list.mdx index e0cb69de1..bc60c4adb 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/list.mdx @@ -28,7 +28,7 @@ List all data products with optional filtering and pagination. - Comma-separated list of fields to include: `owners`, `domain`, `experts`, `assets`. See [Supported Fields](#supported-fields) below. + Comma-separated list of fields to include: `owners`, `domains`, `experts`, `assets`. See [Supported Fields](#supported-fields) below. @@ -47,44 +47,46 @@ configure( # List first page products = DataProducts.list(limit=50) -for dp in products.data: - print(f"{dp.fullyQualifiedName}") +for dp in products.entities: + print(f"{dp.fullyQualifiedName.root}") # List all with auto-pagination for dp in DataProducts.list_all(): - print(f"{dp.fullyQualifiedName}") + print(f"{dp.fullyQualifiedName.root}") # Filter by domain with fields products = DataProducts.list( - domain="Marketing", - fields=["owners", "domain", "experts", "assets"], + filters={"domain": "Marketing"}, + fields=["owners", "domains", "experts", "assets"], limit=50 ) -for dp in products.data: - print(f"{dp.fullyQualifiedName}") +for dp in products.entities: + print(f"{dp.fullyQualifiedName.root}") if dp.owners: - print(f" Owners: {[o.name for o in dp.owners]}") + print(f" Owners: {[o.name for o in dp.owners.root]}") ``` ```java GET /v1/dataProducts -import static org.openmetadata.sdk.fluent.DataProducts.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = DataProducts.list() - .limit(50) - .execute(); - -for (var dp : result.getData()) { - System.out.println(dp.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.dataProducts().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by domain with fields -var result = DataProducts.list() - .domain("Marketing") - .fields("owners", "domain", "experts", "assets") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("domain", "Marketing") + .setFields("owners,domains,experts,assets") + .setLimit(50); +var filteredPage = client.dataProducts().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/dataProducts @@ -93,7 +95,7 @@ curl "{base_url}/api/v1/dataProducts?limit=50" \ -H "Authorization: Bearer {access_token}" # Filter by domain -curl "{base_url}/api/v1/dataProducts?domain=Marketing&fields=owners,domain,experts,assets&limit=50" \ +curl "{base_url}/api/v1/dataProducts?domain=Marketing&fields=owners,domains,experts,assets&limit=50" \ -H "Authorization: Bearer {access_token}" ``` @@ -105,20 +107,22 @@ curl "{base_url}/api/v1/dataProducts?domain=Marketing&fields=owners,domain,exper { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Curated customer analytics data product", "version": 0.1, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -153,11 +157,11 @@ Returns a paginated list of data product objects. By default, only basic fields - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. - - Parent domain reference. Only included when `fields` contains `domain`. + + Parent domain references. Only included when `fields` contains `domains`. @@ -199,7 +203,7 @@ Returns a paginated list of data product objects. By default, only basic fields | Field | Description | |-------|-------------| | `owners` | Owner references (users and teams) | -| `domain` | Parent domain reference | +| `domains` | Parent domain references | | `experts` | Subject matter expert references | | `assets` | Associated data assets | diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/ports-assets.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/ports-assets.mdx index b809ceab6..c3f155b98 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/ports-assets.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/ports-assets.mdx @@ -14,7 +14,7 @@ Manage the input ports, output ports, and associated assets of a data product. T Use `PUT /v1/dataProducts/{fqn}/assets/add` to add assets to a data product. - Fully qualified name of the data product, such as `Marketing.CustomerInsights`. + Fully qualified name of the data product, such as `CustomerInsights`. @@ -26,7 +26,7 @@ Use `PUT /v1/dataProducts/{fqn}/assets/add` to add assets to a data product. - Type of asset entity (e.g., `table`, `topic`, `dashboard`, `pipeline`). + Type of asset entity, for example `table`, `topic`, `dashboard`, `pipeline`. @@ -36,7 +36,7 @@ Use `PUT /v1/dataProducts/{fqn}/assets/add` to add assets to a data product. Use `PUT /v1/dataProducts/{fqn}/assets/remove` to remove assets from a data product. - Fully qualified name of the data product, such as `Marketing.CustomerInsights`. + Fully qualified name of the data product, such as `CustomerInsights`. @@ -48,7 +48,7 @@ Use `PUT /v1/dataProducts/{fqn}/assets/remove` to remove assets from a data prod - Type of asset entity (e.g., `table`, `topic`, `dashboard`, `pipeline`). + Type of asset entity, for example `table`, `topic`, `dashboard`, `pipeline`. @@ -64,68 +64,82 @@ configure( jwt_token="your-jwt-token" ) -# Identify the data product by its fully qualified name, and each asset by its UUID. +# Identify the data product by its name, which is also its fully qualified name, and each asset by its UUID. # Add input ports DataProducts.add_input_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-1", type="table")] ) # Remove input ports DataProducts.remove_input_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-1", type="table")] ) # Add output ports DataProducts.add_output_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="dashboard-uuid-1", type="dashboard")] ) # Remove output ports DataProducts.remove_output_ports( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="dashboard-uuid-1", type="dashboard")] ) # Add assets DataProducts.add_assets( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-2", type="table")] ) # Remove assets DataProducts.remove_assets( - "Marketing.CustomerInsights", + "CustomerInsights", [EntityReference(id="table-uuid-2", type="table")] ) ``` ```java PUT /v1/dataProducts/{fqn}/assets/add -import static org.openmetadata.sdk.fluent.DataProducts.*; +import java.util.List; +import java.util.UUID; +import org.openmetadata.schema.type.EntityReference; +import org.openmetadata.schema.type.api.BulkAssets; -// Identify the data product by its fully qualified name, and each asset by its UUID. +// client is an initialized OpenMetadataClient. +var dataProduct = "CustomerInsights"; + +var tables = new BulkAssets().withAssets(List.of( + new EntityReference() + .withId(UUID.fromString("5b3d9f0e-1c7a-4d2e-9a61-3f8e2b7c4d10")) + .withType("table"))); + +// Identify the data product by its name, which is also its fully qualified name, and each asset by its UUID. // Add assets -DataProducts.addAssets( - "Marketing.CustomerInsights", - List.of(new EntityReference("table-uuid-1", "table")) -); +var added = client.dataProducts().bulkAddAssets(dataProduct, tables); +System.out.println(added.getStatus()); // Remove assets -DataProducts.removeAssets( - "Marketing.CustomerInsights", - List.of(new EntityReference("table-uuid-1", "table")) -); +var removed = client.dataProducts().bulkRemoveAssets(dataProduct, tables); + +// Add and remove input ports +client.dataProducts().bulkAddInputPorts(dataProduct, tables); +client.dataProducts().bulkRemoveInputPorts(dataProduct, tables); + +// Add and remove output ports +client.dataProducts().bulkAddOutputPorts(dataProduct, tables); +client.dataProducts().bulkRemoveOutputPorts(dataProduct, tables); ``` ```bash PUT /v1/dataProducts/{fqn}/assets/add # The path identifier is the data product's fully qualified name. URL-encode it if it contains spaces. # Add assets -curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/add" \ +curl -X PUT "{base_url}/api/v1/dataProducts/CustomerInsights/assets/add" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -136,7 +150,7 @@ curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/ad }' # Remove assets -curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/remove" \ +curl -X PUT "{base_url}/api/v1/dataProducts/CustomerInsights/assets/remove" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json" \ -d '{ @@ -152,19 +166,21 @@ curl -X PUT "{base_url}/api/v1/dataProducts/Marketing.CustomerInsights/assets/re { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "description": "Curated customer analytics data product", "version": 0.3, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/retrieve.mdx index b08cd3a49..ec3da59a5 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/retrieve.mdx @@ -16,7 +16,7 @@ Get a single data product by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,domain,experts,assets`). + Comma-separated list of fields to include, for example `owners,domains,experts,assets`. @@ -28,11 +28,11 @@ Get a single data product by its unique ID or fully qualified name. Use `GET /v1/dataProducts/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the data product (e.g., `Marketing.CustomerInsights`). + Fully qualified name of the data product, for example `CustomerInsights`. - Comma-separated list of fields to include: `owners`, `domain`, `experts`, `assets`. + Comma-separated list of fields to include: `owners`, `domains`, `experts`, `assets`. @@ -51,44 +51,40 @@ configure( # Get by ID dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2") -print(f"{dp.fullyQualifiedName}: {dp.description}") +print(f"{dp.fullyQualifiedName.root}: {getattr(dp.description, 'root', dp.description)}") # Get by ID with fields dp = DataProducts.retrieve( "b1839f98-f046-5f35-bdef-20f9b3395cb2", - fields=["owners", "domain", "experts", "assets"] + fields=["owners", "domains", "experts", "assets"] ) # Get by fully qualified name -dp = DataProducts.retrieve_by_name("Marketing.CustomerInsights") +dp = DataProducts.retrieve_by_name("CustomerInsights") # Get by name with fields dp = DataProducts.retrieve_by_name( - "Marketing.CustomerInsights", - fields=["owners", "domain", "experts", "assets"] + "CustomerInsights", + fields=["owners", "domains", "experts", "assets"] ) ``` ```java GET /v1/dataProducts/{id} -import static org.openmetadata.sdk.fluent.DataProducts.*; - -// Get by ID -var dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2"); +// client is an initialized OpenMetadataClient. +var dataProduct = client.dataProducts().get("b1839f98-f046-5f35-bdef-20f9b3395cb2"); // Get by ID with fields -var dp = DataProducts.retrieve( +var dataProductWithFields = client.dataProducts().get( "b1839f98-f046-5f35-bdef-20f9b3395cb2", - "owners,domain,experts,assets" -); + "owners,domains,experts,assets"); // Get by fully qualified name -var dp = DataProducts.retrieveByName("Marketing.CustomerInsights"); +var dataProductByName = client.dataProducts().getByName("CustomerInsights"); // Get by name with fields -var dp = DataProducts.retrieveByName( - "Marketing.CustomerInsights", - "owners,domain,experts,assets" -); +var dataProductByNameWithFields = client.dataProducts().getByName( + "CustomerInsights", + "owners,domains,experts,assets"); ``` ```bash GET /v1/dataProducts/{id} @@ -97,15 +93,15 @@ curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2" \ -H "Authorization: Bearer {access_token}" # Get by ID with fields -curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2?fields=owners,domain,experts,assets" \ +curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2?fields=owners,domains,experts,assets" \ -H "Authorization: Bearer {access_token}" # Get by fully qualified name -curl "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ +curl "{base_url}/api/v1/dataProducts/name/CustomerInsights" \ -H "Authorization: Bearer {access_token}" # Get by name with fields -curl "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights?fields=owners,domain,experts,assets" \ +curl "{base_url}/api/v1/dataProducts/name/CustomerInsights?fields=owners,domains,experts,assets" \ -H "Authorization: Bearer {access_token}" ``` @@ -115,20 +111,22 @@ curl "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights?fields=owne { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Curated customer analytics data product", "version": 0.1, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -153,7 +151,7 @@ Returns a data product object with all requested fields populated. - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. @@ -164,8 +162,8 @@ Returns a data product object with all requested fields populated. Description of the data product in Markdown format. - - Reference to the parent domain. + + References to the parent domains. diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/update.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/update.mdx index dc585f0ad..3b1f66389 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/update.mdx @@ -20,7 +20,7 @@ Update a data product's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/dataProducts/name/{fqn}` to update by fully qualified name. - Fully qualified name of the data product (e.g., `Marketing.CustomerInsights`). + Fully qualified name of the data product, for example `CustomerInsights`. ## Body Parameters @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -78,16 +78,16 @@ dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2") dp.description = "Updated: Curated customer analytics with enriched profiles" updated = DataProducts.update(dp) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/dataProducts/{id} -import static org.openmetadata.sdk.fluent.DataProducts.*; +// client is an initialized OpenMetadataClient. +var dataProductId = "b1839f98-f046-5f35-bdef-20f9b3395cb2"; +var dataProduct = client.dataProducts().get(dataProductId); +dataProduct.setDescription("Updated: Curated customer analytics with enriched profiles"); -// Retrieve, modify, and update -var dp = DataProducts.retrieve("b1839f98-f046-5f35-bdef-20f9b3395cb2"); -dp.setDescription("Updated: Curated customer analytics with enriched profiles"); -var updated = DataProducts.update(dp); +var updated = client.dataProducts().update(dataProductId, dataProduct); ``` ```bash PATCH /v1/dataProducts/{id} @@ -100,7 +100,7 @@ curl -X PATCH "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395c ]' # Update by name -curl -X PATCH "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ +curl -X PATCH "{base_url}/api/v1/dataProducts/name/CustomerInsights" \ -H "Authorization: Bearer {access_token}" \ -H "Content-Type: application/json-patch+json" \ -d '[ @@ -114,20 +114,22 @@ curl -X PATCH "{base_url}/api/v1/dataProducts/name/Marketing.CustomerInsights" \ { "id": "b1839f98-f046-5f35-bdef-20f9b3395cb2", "name": "CustomerInsights", - "fullyQualifiedName": "Marketing.CustomerInsights", + "fullyQualifiedName": "CustomerInsights", "displayName": "Customer Insights", "description": "Updated: Curated customer analytics with enriched profiles", "version": 0.2, "updatedAt": 1769984330261, "updatedBy": "admin", "href": "http://localhost:8585/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2", - "domain": { - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "type": "domain", - "name": "Marketing", - "fullyQualifiedName": "Marketing", - "deleted": false - }, + "domains": [ + { + "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", + "type": "domain", + "name": "Marketing", + "fullyQualifiedName": "Marketing", + "deleted": false + } + ], "deleted": false, "owners": [], "experts": [] @@ -152,7 +154,7 @@ Returns the updated data product object with the new version number. - Fully qualified name in format `domain.dataProductName`. + Fully qualified name of the data product. This is the data product name. diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/versions.mdx index 7030bc159..e43febe9a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/data-products/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/data-products/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/dataProducts/{id}/versions/{version}` to retrieve a specific versio - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/dataProducts/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import DataProducts @@ -40,31 +42,29 @@ configure( # List all versions versions = DataProducts.get_versions("b1839f98-f046-5f35-bdef-20f9b3395cb2") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version dp_v1 = DataProducts.get_specific_version( "b1839f98-f046-5f35-bdef-20f9b3395cb2", "0.1" ) -print(f"Original description: {dp_v1.description}") +print(f"Original description: {getattr(dp_v1.description, 'root', dp_v1.description)}") ``` ```java GET /v1/dataProducts/{id}/versions -import static org.openmetadata.sdk.fluent.DataProducts.*; +// client is an initialized OpenMetadataClient. +var id = "b1839f98-f046-5f35-bdef-20f9b3395cb2"; // List all versions -var history = DataProducts.getVersions("b1839f98-f046-5f35-bdef-20f9b3395cb2"); - +var history = client.dataProducts().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = DataProducts.getSpecificVersion( - "b1839f98-f046-5f35-bdef-20f9b3395cb2", - 0.1 -); +var v1 = client.dataProducts().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` @@ -84,8 +84,8 @@ curl "{base_url}/api/v1/dataProducts/b1839f98-f046-5f35-bdef-20f9b3395cb2/versio { "entityType": "dataProduct", "versions": [ - "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"Marketing.CustomerInsights\",\"version\":0.2,\"description\":\"Updated description\"}", - "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"Marketing.CustomerInsights\",\"version\":0.1,\"description\":\"Curated customer analytics data product\"}" + "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"CustomerInsights\",\"version\":0.2,\"description\":\"Updated description\"}", + "{\"id\":\"b1839f98-f046-5f35-bdef-20f9b3395cb2\",\"name\":\"CustomerInsights\",\"fullyQualifiedName\":\"CustomerInsights\",\"version\":0.1,\"description\":\"Curated customer analytics data product\"}" ] } ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/domains/create.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/domains/create.mdx index f728e4c2f..7cb7f51dc 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/domains/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/domains/create.mdx @@ -28,7 +28,7 @@ Create a new domain for organizing data assets by business area. - Fully qualified name of the parent domain for creating nested domains (e.g., `Engineering`). + Fully qualified name of the parent domain for creating nested domains, for example `Engineering`. @@ -40,7 +40,7 @@ Create a new domain for organizing data assets by business area. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -86,19 +86,20 @@ request = CreateDomainRequest( ) domain = Domains.create(request) -print(f"Created: {domain.fullyQualifiedName}") +print(f"Created: {domain.fullyQualifiedName.root}") ``` ```java POST /v1/domains -import static org.openmetadata.sdk.fluent.Domains.*; - -// Create using builder pattern -var domain = Domains.builder() - .name("TestDomain") - .displayName("Test Domain") - .domainType("Aggregate") - .description("Lorem ipsum...") - .create(); +import org.openmetadata.schema.api.domains.CreateDomain; + +// client is an initialized OpenMetadataClient. +var request = new CreateDomain() + .withName("TestDomain") + .withDisplayName("Test Domain") + .withDomainType(CreateDomain.DomainType.AGGREGATE) + .withDescription("Lorem ipsum..."); + +var domain = client.domains().create(request); ``` ```bash POST /v1/domains @@ -151,7 +152,7 @@ Returns the created domain object with all specified properties and system-gener - Fully qualified name (e.g., `TestDomain` or `parent.child`). + Fully qualified name, for example `TestDomain` or `parent.child`. @@ -175,7 +176,7 @@ Returns the created domain object with all specified properties and system-gener - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/domains/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/domains/delete.mdx index 34f12b830..0a57d3099 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/domains/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/domains/delete.mdx @@ -1,13 +1,13 @@ --- title: Delete a Domain -description: Delete a domain by ID or name, with soft/hard delete options +description: Delete a domain by ID or name, permanently sidebarTitle: Delete a Domain api: DELETE /v1/domains/{id} --- # Delete a Domain -Delete a domain by ID or fully qualified name. Supports soft delete (default), hard delete, and restore operations. +Delete a domain by ID or fully qualified name. Deleting a domain is permanent. A deleted domain can't be restored. ## Delete by ID @@ -20,7 +20,7 @@ Delete a domain by ID or fully qualified name. Supports soft delete (default), h - Permanently delete the domain. If `false`, the domain is soft-deleted and can be restored. + Not needed. A deleted domain is always permanently deleted, with or without this option. ## Delete by Name @@ -28,7 +28,7 @@ Delete a domain by ID or fully qualified name. Supports soft delete (default), h Use `DELETE /v1/domains/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the domain (e.g., `TestDomain`). + Fully qualified name of the domain, for example `TestDomain`. @@ -36,15 +36,7 @@ Use `DELETE /v1/domains/name/{fqn}` to delete by fully qualified name. - Permanently delete the domain. - - -## Restore a Soft-Deleted Domain - -Use `PUT /v1/domains/restore` to restore a soft-deleted domain. - - - UUID of the soft-deleted domain to restore. + Not needed. A deleted domain is always permanently deleted, with or without this option. @@ -57,90 +49,59 @@ configure( jwt_token="your-jwt-token" ) -# Soft delete by ID +# Delete by ID Domains.delete("a0729e98-e946-4e25-acde-10e8a2294ba1") -# Hard delete +# Delete by ID with options Domains.delete( "a0729e98-e946-4e25-acde-10e8a2294ba1", hard_delete=True ) # Delete by name -Domains.delete_by_name("TestDomain") +Domains.delete(Domains.retrieve_by_name("TestDomain").id) # Delete by name with options -Domains.delete_by_name( - "TestDomain", +Domains.delete( + Domains.retrieve_by_name("TestDomain").id, hard_delete=True ) - -# Restore a soft-deleted domain -Domains.restore("a0729e98-e946-4e25-acde-10e8a2294ba1") ``` ```java DELETE /v1/domains/{id} -import static org.openmetadata.sdk.fluent.Domains.*; +import java.util.Map; -// Soft delete -Domains.delete("a0729e98-e946-4e25-acde-10e8a2294ba1").execute(); +// client is an initialized OpenMetadataClient. +var id = "a0729e98-e946-4e25-acde-10e8a2294ba1"; -// Hard delete -Domains.delete("a0729e98-e946-4e25-acde-10e8a2294ba1") - .hardDelete() - .execute(); - -// Delete by name -Domains.deleteByName("TestDomain").execute(); +// Delete (permanent) +client.domains().delete(id); -// Restore -Domains.restore("a0729e98-e946-4e25-acde-10e8a2294ba1"); +// Delete by name: look up the ID first +var domain = client.domains().getByName("TestDomain"); +client.domains().delete(domain.getId().toString()); ``` ```bash DELETE /v1/domains/{id} -# Soft delete by ID +# Delete by ID curl -X DELETE "{base_url}/api/v1/domains/a0729e98-e946-4e25-acde-10e8a2294ba1" \ -H "Authorization: Bearer {access_token}" -# Hard delete +# Delete with options curl -X DELETE "{base_url}/api/v1/domains/a0729e98-e946-4e25-acde-10e8a2294ba1?hardDelete=true" \ -H "Authorization: Bearer {access_token}" # Delete by name curl -X DELETE "{base_url}/api/v1/domains/name/TestDomain" \ -H "Authorization: Bearer {access_token}" - -# Restore soft-deleted domain -curl -X PUT "{base_url}/api/v1/domains/restore" \ - -H "Authorization: Bearer {access_token}" \ - -H "Content-Type: application/json" \ - -d '{"id": "a0729e98-e946-4e25-acde-10e8a2294ba1"}' ``` - -```json Response (Soft Delete) -{ - "id": "a0729e98-e946-4e25-acde-10e8a2294ba1", - "domainType": "Aggregate", - "name": "TestDomain", - "fullyQualifiedName": "TestDomain", - "description": "Lorem ipsum...", - "version": 0.2, - "updatedAt": 1769984330261, - "updatedBy": "admin", - "deleted": true, - "owners": [], - "children": [] -} -``` - - --- ## Returns -Soft delete returns the domain object with `deleted: true`. Hard delete returns no content (204). Restore returns the restored domain object. +Returns `200` with no content. The domain is permanently deleted and can't be restored. --- diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/domains/list.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/domains/list.mdx index 5d6c7a1a3..64de0eb0d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/domains/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/domains/list.mdx @@ -59,12 +59,12 @@ configure( # List first page domains = Domains.list(limit=50) -for d in domains.data: - print(f"{d.fullyQualifiedName} ({d.domainType})") +for d in domains.entities: + print(f"{d.fullyQualifiedName.root} ({d.domainType})") # List all with auto-pagination for d in Domains.list_all(): - print(f"{d.fullyQualifiedName}") + print(f"{d.fullyQualifiedName.root}") # With fields domains = Domains.list( @@ -72,32 +72,30 @@ domains = Domains.list( limit=50 ) -for d in domains.data: - print(f"{d.fullyQualifiedName}") +for d in domains.entities: + print(f"{d.fullyQualifiedName.root}") if d.owners: - print(f" Owners: {[o.name for o in d.owners]}") + print(f" Owners: {[o.name for o in d.owners.root]}") ``` ```java GET /v1/domains -import static org.openmetadata.sdk.fluent.Domains.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Domains.list() - .limit(50) - .execute(); - -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.domains().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // With fields -var result = Domains.list() - .fields("owners", "children", "experts") - .limit(50) - .execute(); - -for (var d : result.getData()) { - System.out.println(d.getFullyQualifiedName()); +var filtered = new ListParams() + .setFields("owners,children,experts") + .setLimit(50); +var filteredPage = client.domains().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/domains/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/domains/retrieve.mdx index 9afb82fe8..2fcbb7281 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/domains/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/domains/retrieve.mdx @@ -16,7 +16,7 @@ Get a single domain by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,children,experts`). + Comma-separated list of fields to include, for example `owners,children,experts`. @@ -28,7 +28,7 @@ Get a single domain by its unique ID or fully qualified name. Use `GET /v1/domains/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the domain (e.g., `TestDomain` or `Engineering.DataPlatform`). + Fully qualified name of the domain, for example `TestDomain` or `Engineering.DataPlatform`. @@ -51,7 +51,7 @@ configure( # Get by ID domain = Domains.retrieve("a0729e98-e946-4e25-acde-10e8a2294ba1") -print(f"{domain.fullyQualifiedName}: {domain.domainType}") +print(f"{domain.fullyQualifiedName.root}: {domain.domainType}") # Get by ID with fields domain = Domains.retrieve( @@ -70,22 +70,21 @@ domain = Domains.retrieve_by_name( ``` ```java GET /v1/domains/{id} -import static org.openmetadata.sdk.fluent.Domains.*; - -// Get by ID -var domain = Domains.retrieve("a0729e98-e946-4e25-acde-10e8a2294ba1"); +// client is an initialized OpenMetadataClient. +var domain = client.domains().get("a0729e98-e946-4e25-acde-10e8a2294ba1"); // Get by ID with fields -var domain = Domains.retrieve( +var domainWithFields = client.domains().get( "a0729e98-e946-4e25-acde-10e8a2294ba1", - "owners,children,experts" -); + "owners,children,experts"); // Get by fully qualified name -var domain = Domains.retrieveByName("TestDomain"); +var domainByName = client.domains().getByName("TestDomain"); // Get by name with fields -var domain = Domains.retrieveByName("TestDomain", "owners,children,experts"); +var domainByNameWithFields = client.domains().getByName( + "TestDomain", + "owners,children,experts"); ``` ```bash GET /v1/domains/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/domains/update.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/domains/update.mdx index 523e20d99..5ceb715d9 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/domains/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/domains/update.mdx @@ -20,7 +20,7 @@ Update a domain's properties using JSON Merge Patch. You can update by ID or by Use `PATCH /v1/domains/name/{fqn}` to update by fully qualified name. - Fully qualified name of the domain (e.g., `TestDomain`). + Fully qualified name of the domain, for example `TestDomain`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -83,16 +83,16 @@ domain.description = "Updated domain description for business analytics" domain.domainType = "Consumer-aligned" updated = Domains.update(domain) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/domains/{id} -import static org.openmetadata.sdk.fluent.Domains.*; - -// Retrieve, modify, and update -var domain = Domains.retrieve("a0729e98-e946-4e25-acde-10e8a2294ba1"); +// client is an initialized OpenMetadataClient. +var domainId = "a0729e98-e946-4e25-acde-10e8a2294ba1"; +var domain = client.domains().get(domainId); domain.setDescription("Updated domain description for business analytics"); -var updated = Domains.update(domain); + +var updated = client.domains().update(domainId, domain); ``` ```bash PATCH /v1/domains/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/domains/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/domains/versions.mdx index 9d30b534f..ccd59ec1c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/domains/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/domains/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/domains/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/domains/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Domains @@ -40,31 +42,29 @@ configure( # List all versions versions = Domains.get_versions("a0729e98-e946-4e25-acde-10e8a2294ba1") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version domain_v1 = Domains.get_specific_version( "a0729e98-e946-4e25-acde-10e8a2294ba1", "0.1" ) -print(f"Original description: {domain_v1.description}") +print(f"Original description: {getattr(domain_v1.description, 'root', domain_v1.description)}") ``` ```java GET /v1/domains/{id}/versions -import static org.openmetadata.sdk.fluent.Domains.*; +// client is an initialized OpenMetadataClient. +var id = "a0729e98-e946-4e25-acde-10e8a2294ba1"; // List all versions -var history = Domains.getVersions("a0729e98-e946-4e25-acde-10e8a2294ba1"); - +var history = client.domains().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Domains.getSpecificVersion( - "a0729e98-e946-4e25-acde-10e8a2294ba1", - 0.1 -); +var v1 = client.domains().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/create.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/create.mdx index fb0b061b0..11a8d93cc 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/create.mdx @@ -32,7 +32,7 @@ Create a new glossary for organizing business terminology. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -68,17 +68,17 @@ Create a new glossary for organizing business terminology. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -104,19 +104,20 @@ request = CreateGlossaryRequest( ) glossary = Glossaries.create(request) -print(f"Created: {glossary.fullyQualifiedName}") +print(f"Created: {glossary.fullyQualifiedName.root}") ``` ```java POST /v1/glossaries -import static org.openmetadata.sdk.fluent.Glossaries.*; - -// Create using builder pattern -var glossary = Glossaries.builder() - .name("BusinessGlossary") - .displayName("Business Glossary") - .description("Standard business terminology for the organization") - .mutuallyExclusive(false) - .create(); +import org.openmetadata.schema.api.data.CreateGlossary; + +// client is an initialized OpenMetadataClient. +var request = new CreateGlossary() + .withName("BusinessGlossary") + .withDisplayName("Business Glossary") + .withDescription("Standard business terminology for the organization") + .withMutuallyExclusive(false); + +var glossary = client.glossaries().create(request); ``` ```bash POST /v1/glossaries diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/delete.mdx index 63176eda3..eea441b08 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/delete.mdx @@ -28,7 +28,7 @@ Delete a glossary by ID or fully qualified name. Supports soft delete (default), Use `DELETE /v1/glossaries/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the glossary (e.g., `BusinessGlossary`). + Fully qualified name of the glossary, for example `BusinessGlossary`. @@ -67,28 +67,30 @@ Glossaries.delete( ) # Delete by name -Glossaries.delete_by_name("BusinessGlossary") +Glossaries.delete(Glossaries.retrieve_by_name("BusinessGlossary").id) # Restore a soft-deleted glossary Glossaries.restore("c2940a98-f147-6g46-cdef-31f0c4406dc3") ``` ```java DELETE /v1/glossaries/{id} -import static org.openmetadata.sdk.fluent.Glossaries.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "c2940a98-f147-6g46-cdef-31f0c4406dc3"; // Soft delete -Glossaries.delete("c2940a98-f147-6g46-cdef-31f0c4406dc3").execute(); +client.glossaries().delete(id); -// Hard delete -Glossaries.delete("c2940a98-f147-6g46-cdef-31f0c4406dc3") - .hardDelete() - .execute(); +// Restore +client.glossaries().restore(id); -// Delete by name -Glossaries.deleteByName("BusinessGlossary").execute(); +// Hard delete +client.glossaries().delete(id, Map.of("hardDelete", "true")); -// Restore -Glossaries.restore("c2940a98-f147-6g46-cdef-31f0c4406dc3"); +// Delete by name: look up the ID first +var glossary = client.glossaries().getByName("BusinessGlossary"); +client.glossaries().delete(glossary.getId().toString()); ``` ```bash DELETE /v1/glossaries/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/list.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/list.mdx index f22003d70..29fa57f6c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/list.mdx @@ -43,12 +43,12 @@ configure( # List first page glossaries = Glossaries.list(limit=50) -for g in glossaries.data: - print(f"{g.fullyQualifiedName}") +for g in glossaries.entities: + print(f"{g.fullyQualifiedName.root}") # List all with auto-pagination for g in Glossaries.list_all(): - print(f"{g.fullyQualifiedName}") + print(f"{g.fullyQualifiedName.root}") # With fields glossaries = Glossaries.list( @@ -56,29 +56,31 @@ glossaries = Glossaries.list( limit=50 ) -for g in glossaries.data: - print(f"{g.fullyQualifiedName}") +for g in glossaries.entities: + print(f"{g.fullyQualifiedName.root}") if g.reviewers: print(f" Reviewers: {[r.name for r in g.reviewers]}") ``` ```java GET /v1/glossaries -import static org.openmetadata.sdk.fluent.Glossaries.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Glossaries.list() - .limit(50) - .execute(); - -for (var g : result.getData()) { - System.out.println(g.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.glossaries().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // With fields -var result = Glossaries.list() - .fields("owners", "tags", "reviewers") - .limit(50) - .execute(); +var filtered = new ListParams() + .setFields("owners,tags,reviewers") + .setLimit(50); +var filteredPage = client.glossaries().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/glossaries diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/retrieve.mdx index 363d22fdd..275ed83fa 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/retrieve.mdx @@ -16,7 +16,7 @@ Get a single glossary by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains,reviewers`). + Comma-separated list of fields to include, for example `owners,tags,domains,reviewers`. @@ -28,7 +28,7 @@ Get a single glossary by its unique ID or fully qualified name. Use `GET /v1/glossaries/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the glossary (e.g., `BusinessGlossary`). + Fully qualified name of the glossary, for example `BusinessGlossary`. @@ -51,7 +51,7 @@ configure( # Get by ID glossary = Glossaries.retrieve("c2940a98-f147-6g46-cdef-31f0c4406dc3") -print(f"{glossary.fullyQualifiedName}: {glossary.description}") +print(f"{glossary.fullyQualifiedName.root}: {getattr(glossary.description, 'root', glossary.description)}") # Get by ID with fields glossary = Glossaries.retrieve( @@ -70,22 +70,21 @@ glossary = Glossaries.retrieve_by_name( ``` ```java GET /v1/glossaries/{id} -import static org.openmetadata.sdk.fluent.Glossaries.*; - -// Get by ID -var glossary = Glossaries.retrieve("c2940a98-f147-6g46-cdef-31f0c4406dc3"); +// client is an initialized OpenMetadataClient. +var glossary = client.glossaries().get("c2940a98-f147-6g46-cdef-31f0c4406dc3"); // Get by ID with fields -var glossary = Glossaries.retrieve( +var glossaryWithFields = client.glossaries().get( "c2940a98-f147-6g46-cdef-31f0c4406dc3", - "owners,tags,reviewers" -); + "owners,tags,reviewers"); // Get by fully qualified name -var glossary = Glossaries.retrieveByName("BusinessGlossary"); +var glossaryByName = client.glossaries().getByName("BusinessGlossary"); // Get by name with fields -var glossary = Glossaries.retrieveByName("BusinessGlossary", "owners,tags,reviewers"); +var glossaryByNameWithFields = client.glossaries().getByName( + "BusinessGlossary", + "owners,tags,reviewers"); ``` ```bash GET /v1/glossaries/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/update.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/update.mdx index 8bcb58598..9fb29ea9b 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/update.mdx @@ -20,7 +20,7 @@ Update a glossary's properties using JSON Merge Patch. You can update by ID or b Use `PATCH /v1/glossaries/name/{fqn}` to update by fully qualified name. - Fully qualified name of the glossary (e.g., `BusinessGlossary`). + Fully qualified name of the glossary, for example `BusinessGlossary`. ## Body Parameters @@ -48,7 +48,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -76,17 +76,17 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -105,16 +105,16 @@ glossary.description = "Updated: Comprehensive business terminology dictionary" glossary.mutuallyExclusive = True updated = Glossaries.update(glossary) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/glossaries/{id} -import static org.openmetadata.sdk.fluent.Glossaries.*; - -// Retrieve, modify, and update -var glossary = Glossaries.retrieve("c2940a98-f147-6g46-cdef-31f0c4406dc3"); +// client is an initialized OpenMetadataClient. +var glossaryId = "c2940a98-f147-6g46-cdef-31f0c4406dc3"; +var glossary = client.glossaries().get(glossaryId); glossary.setDescription("Updated: Comprehensive business terminology dictionary"); -var updated = Glossaries.update(glossary); + +var updated = client.glossaries().update(glossaryId, glossary); ``` ```bash PATCH /v1/glossaries/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/versions.mdx index 979d53ed4..8ee8acd38 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossaries/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/glossaries/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/glossaries/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Glossaries @@ -40,31 +42,29 @@ configure( # List all versions versions = Glossaries.get_versions("c2940a98-f147-6g46-cdef-31f0c4406dc3") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version glossary_v1 = Glossaries.get_specific_version( "c2940a98-f147-6g46-cdef-31f0c4406dc3", "0.1" ) -print(f"Original description: {glossary_v1.description}") +print(f"Original description: {getattr(glossary_v1.description, 'root', glossary_v1.description)}") ``` ```java GET /v1/glossaries/{id}/versions -import static org.openmetadata.sdk.fluent.Glossaries.*; +// client is an initialized OpenMetadataClient. +var id = "c2940a98-f147-6g46-cdef-31f0c4406dc3"; // List all versions -var history = Glossaries.getVersions("c2940a98-f147-6g46-cdef-31f0c4406dc3"); - +var history = client.glossaries().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Glossaries.getSpecificVersion( - "c2940a98-f147-6g46-cdef-31f0c4406dc3", - 0.1 -); +var v1 = client.glossaries().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/create.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/create.mdx index dc3fc9f08..65e05d992 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/create.mdx @@ -16,7 +16,7 @@ Create a new glossary term within a glossary. - Fully qualified name of the parent glossary (e.g., `BusinessGlossary`). + Fully qualified name of the parent glossary, for example `BusinessGlossary`. @@ -28,7 +28,7 @@ Create a new glossary term within a glossary. - Fully qualified name of the parent glossary term for creating nested terms (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the parent glossary term for creating nested terms, for example `BusinessGlossary.Revenue`. @@ -48,7 +48,7 @@ Create a new glossary term within a glossary. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,17 +66,17 @@ Create a new glossary term within a glossary. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -84,7 +84,7 @@ Create a new glossary term within a glossary. - Hex color code (e.g., `#FF5733`). + Hex color code, for example `#FF5733`. @@ -113,20 +113,22 @@ request = CreateGlossaryTermRequest( ) term = GlossaryTerms.create(request) -print(f"Created: {term.fullyQualifiedName}") +print(f"Created: {term.fullyQualifiedName.root}") ``` ```java POST /v1/glossaryTerms -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; - -// Create using builder pattern -var term = GlossaryTerms.builder() - .name("Revenue") - .glossary("BusinessGlossary") - .displayName("Revenue") - .description("Total income generated from business operations") - .synonyms(List.of("Income", "Earnings", "Sales")) - .create(); +import java.util.List; +import org.openmetadata.schema.api.data.CreateGlossaryTerm; + +// client is an initialized OpenMetadataClient. +var request = new CreateGlossaryTerm() + .withName("Revenue") + .withGlossary("BusinessGlossary") + .withDisplayName("Revenue") + .withDescription("Total income generated from business operations") + .withSynonyms(List.of("Income", "Earnings", "Sales")); + +var term = client.glossaryTerms().create(request); ``` ```bash POST /v1/glossaryTerms diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/delete.mdx index 59cee26b5..885fa95ea 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/delete.mdx @@ -28,7 +28,7 @@ Delete a glossary term by ID or fully qualified name. Supports soft delete (defa Use `DELETE /v1/glossaryTerms/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the glossary term (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the glossary term, for example `BusinessGlossary.Revenue`. @@ -67,28 +67,30 @@ GlossaryTerms.delete( ) # Delete by name -GlossaryTerms.delete_by_name("BusinessGlossary.Revenue") +GlossaryTerms.delete(GlossaryTerms.retrieve_by_name("BusinessGlossary.Revenue").id) # Restore a soft-deleted glossary term GlossaryTerms.restore("d3a50b09-g258-7h57-defg-42g1d5517ed4") ``` ```java DELETE /v1/glossaryTerms/{id} -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "d3a50b09-g258-7h57-defg-42g1d5517ed4"; // Soft delete -GlossaryTerms.delete("d3a50b09-g258-7h57-defg-42g1d5517ed4").execute(); +client.glossaryTerms().delete(id); -// Hard delete -GlossaryTerms.delete("d3a50b09-g258-7h57-defg-42g1d5517ed4") - .hardDelete() - .execute(); +// Restore +client.glossaryTerms().restore(id); -// Delete by name -GlossaryTerms.deleteByName("BusinessGlossary.Revenue").execute(); +// Hard delete +client.glossaryTerms().delete(id, Map.of("hardDelete", "true")); -// Restore -GlossaryTerms.restore("d3a50b09-g258-7h57-defg-42g1d5517ed4"); +// Delete by name: look up the ID first +var term = client.glossaryTerms().getByName("BusinessGlossary.Revenue"); +client.glossaryTerms().delete(term.getId().toString()); ``` ```bash DELETE /v1/glossaryTerms/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/list.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/list.mdx index 17d391973..50ba82cb0 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/list.mdx @@ -42,7 +42,7 @@ List all glossary terms with optional filtering and pagination. ```python GET /v1/glossaryTerms from metadata.sdk import configure -from metadata.sdk.entities import GlossaryTerms +from metadata.sdk.entities import Glossaries, GlossaryTerms configure( host="https://your-company.open-metadata.org/api", @@ -51,44 +51,47 @@ configure( # List first page terms = GlossaryTerms.list(limit=50) -for t in terms.data: - print(f"{t.fullyQualifiedName}") +for t in terms.entities: + print(f"{t.fullyQualifiedName.root}") # List all with auto-pagination for t in GlossaryTerms.list_all(): - print(f"{t.fullyQualifiedName}") + print(f"{t.fullyQualifiedName.root}") # Filter by glossary with fields +glossary = Glossaries.retrieve_by_name("BusinessGlossary") terms = GlossaryTerms.list( - glossary="c2940a98-f147-4a46-8def-31f0c4406dc3", # glossary ID (UUID) + filters={"glossary": str(glossary.id.root)}, fields=["owners", "tags", "relatedTerms", "children"], limit=50 ) -for t in terms.data: - print(f"{t.fullyQualifiedName}") +for t in terms.entities: + print(f"{t.fullyQualifiedName.root}") if t.synonyms: print(f" Synonyms: {t.synonyms}") ``` ```java GET /v1/glossaryTerms -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = GlossaryTerms.list() - .limit(50) - .execute(); - -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.glossaryTerms().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by glossary with fields -var result = GlossaryTerms.list() - .glossary("c2940a98-f147-4a46-8def-31f0c4406dc3") - .fields("owners", "tags", "relatedTerms", "children") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("glossary", "c2940a98-f147-4a46-8def-31f0c4406dc3") + .setFields("owners,tags,relatedTerms,children") + .setLimit(50); +var filteredPage = client.glossaryTerms().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/glossaryTerms diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/retrieve.mdx index 0bdf84ae2..d55d668ba 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/retrieve.mdx @@ -16,7 +16,7 @@ Get a single glossary term by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,tags,domains,relatedTerms,reviewers,children`). + Comma-separated list of fields to include, for example `owners,tags,domains,relatedTerms,reviewers,children`. @@ -28,7 +28,7 @@ Get a single glossary term by its unique ID or fully qualified name. Use `GET /v1/glossaryTerms/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the glossary term (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the glossary term, for example `BusinessGlossary.Revenue`. @@ -51,7 +51,7 @@ configure( # Get by ID term = GlossaryTerms.retrieve("d3a50b09-g258-7h57-defg-42g1d5517ed4") -print(f"{term.fullyQualifiedName}: {term.description}") +print(f"{term.fullyQualifiedName.root}: {getattr(term.description, 'root', term.description)}") # Get by ID with fields term = GlossaryTerms.retrieve( @@ -70,25 +70,21 @@ term = GlossaryTerms.retrieve_by_name( ``` ```java GET /v1/glossaryTerms/{id} -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; - -// Get by ID -var term = GlossaryTerms.retrieve("d3a50b09-g258-7h57-defg-42g1d5517ed4"); +// client is an initialized OpenMetadataClient. +var term = client.glossaryTerms().get("d3a50b09-g258-7h57-defg-42g1d5517ed4"); // Get by ID with fields -var term = GlossaryTerms.retrieve( +var termWithFields = client.glossaryTerms().get( "d3a50b09-g258-7h57-defg-42g1d5517ed4", - "owners,tags,relatedTerms,children" -); + "owners,tags,relatedTerms,children"); // Get by fully qualified name -var term = GlossaryTerms.retrieveByName("BusinessGlossary.Revenue"); +var termByName = client.glossaryTerms().getByName("BusinessGlossary.Revenue"); // Get by name with fields -var term = GlossaryTerms.retrieveByName( +var termByNameWithFields = client.glossaryTerms().getByName( "BusinessGlossary.Revenue", - "owners,tags,relatedTerms,children" -); + "owners,tags,relatedTerms,children"); ``` ```bash GET /v1/glossaryTerms/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/update.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/update.mdx index f581f5509..9992e9a93 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/update.mdx @@ -20,7 +20,7 @@ Update a glossary term's properties using JSON Merge Patch. You can update by ID Use `PATCH /v1/glossaryTerms/name/{fqn}` to update by fully qualified name. - Fully qualified name of the glossary term (e.g., `BusinessGlossary.Revenue`). + Fully qualified name of the glossary term, for example `BusinessGlossary.Revenue`. ## Body Parameters @@ -52,7 +52,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -66,11 +66,11 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of label (e.g., `Manual`, `Derived`, `Propagated`). + Type of label, for example `Manual`, `Derived`, `Propagated`. - State of the tag (e.g., `Suggested`, `Confirmed`). + State of the tag, for example `Suggested`, `Confirmed`. @@ -80,7 +80,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Hex color code (e.g., `#FF5733`). + Hex color code, for example `#FF5733`. @@ -89,8 +89,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -109,16 +109,16 @@ term.description = "Updated: Total income from all business operations before de term.synonyms = ["Income", "Earnings", "Sales", "Turnover"] updated = GlossaryTerms.update(term) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/glossaryTerms/{id} -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; - -// Retrieve, modify, and update -var term = GlossaryTerms.retrieve("d3a50b09-g258-7h57-defg-42g1d5517ed4"); +// client is an initialized OpenMetadataClient. +var termId = "d3a50b09-g258-7h57-defg-42g1d5517ed4"; +var term = client.glossaryTerms().get(termId); term.setDescription("Updated: Total income from all business operations before deductions"); -var updated = GlossaryTerms.update(term); + +var updated = client.glossaryTerms().update(termId, term); ``` ```bash PATCH /v1/glossaryTerms/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/versions.mdx index b64c53bf9..16998a3d8 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/glossary-terms/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/glossaryTerms/{id}/versions/{version}` to retrieve a specific versi - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/glossaryTerms/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import GlossaryTerms @@ -40,31 +42,29 @@ configure( # List all versions versions = GlossaryTerms.get_versions("d3a50b09-g258-7h57-defg-42g1d5517ed4") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version term_v1 = GlossaryTerms.get_specific_version( "d3a50b09-g258-7h57-defg-42g1d5517ed4", "0.1" ) -print(f"Original description: {term_v1.description}") +print(f"Original description: {getattr(term_v1.description, 'root', term_v1.description)}") ``` ```java GET /v1/glossaryTerms/{id}/versions -import static org.openmetadata.sdk.fluent.GlossaryTerms.*; +// client is an initialized OpenMetadataClient. +var id = "d3a50b09-g258-7h57-defg-42g1d5517ed4"; // List all versions -var history = GlossaryTerms.getVersions("d3a50b09-g258-7h57-defg-42g1d5517ed4"); - +var history = client.glossaryTerms().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = GlossaryTerms.getSpecificVersion( - "d3a50b09-g258-7h57-defg-42g1d5517ed4", - 0.1 -); +var v1 = client.glossaryTerms().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/tags/create.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/tags/create.mdx index 729d1ff42..d6be682af 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/tags/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/tags/create.mdx @@ -16,7 +16,7 @@ Create a new tag within a classification. - Fully qualified name of the parent classification (e.g., `Certification`). + Fully qualified name of the parent classification, for example `Certification`. @@ -28,7 +28,7 @@ Create a new tag within a classification. - Fully qualified name of the parent tag for creating nested tags (e.g., `PII.Sensitive`). + Fully qualified name of the parent tag for creating nested tags, for example `PII.Sensitive`. @@ -36,7 +36,7 @@ Create a new tag within a classification. - Hex color code (e.g., `#C08320`). + Hex color code, for example `#C08320`. @@ -54,7 +54,7 @@ Create a new tag within a classification. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -86,19 +86,21 @@ request = CreateTagRequest( ) tag = Tags.create(request) -print(f"Created: {tag.fullyQualifiedName}") +print(f"Created: {tag.fullyQualifiedName.root}") ``` ```java POST /v1/tags -import static org.openmetadata.sdk.fluent.Tags.*; - -// Create using builder pattern -var tag = Tags.builder() - .name("Bronze") - .classification("Certification") - .description("Bronze certified Data Asset.") - .style(Map.of("color", "#C08320")) - .create(); +import org.openmetadata.schema.api.classification.CreateTag; +import org.openmetadata.schema.entity.type.Style; + +// client is an initialized OpenMetadataClient. +var request = new CreateTag() + .withName("Bronze") + .withClassification("Certification") + .withDescription("Bronze certified Data Asset.") + .withStyle(new Style().withColor("#C08320")); + +var tag = client.tags().create(request); ``` ```bash POST /v1/tags diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/tags/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/tags/delete.mdx index 9bcc64a75..833580aee 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/tags/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/tags/delete.mdx @@ -28,7 +28,7 @@ Delete a tag by ID or fully qualified name. Supports soft delete (default), hard Use `DELETE /v1/tags/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the tag (e.g., `Certification.Bronze`). + Fully qualified name of the tag, for example `Certification.Bronze`. @@ -67,28 +67,30 @@ Tags.delete( ) # Delete by name -Tags.delete_by_name("Certification.Bronze") +Tags.delete(Tags.retrieve_by_name("Certification.Bronze").id) # Restore a soft-deleted tag Tags.restore("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") ``` ```java DELETE /v1/tags/{id} -import static org.openmetadata.sdk.fluent.Tags.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "68ec158c-5f5e-4277-8a19-5e9e0cd5294f"; // Soft delete -Tags.delete("68ec158c-5f5e-4277-8a19-5e9e0cd5294f").execute(); +client.tags().delete(id); -// Hard delete -Tags.delete("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") - .hardDelete() - .execute(); +// Restore +client.tags().restore(id); -// Delete by name -Tags.deleteByName("Certification.Bronze").execute(); +// Hard delete +client.tags().delete(id, Map.of("hardDelete", "true")); -// Restore -Tags.restore("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); +// Delete by name: look up the ID first +var tag = client.tags().getByName("Certification.Bronze"); +client.tags().delete(tag.getId().toString()); ``` ```bash DELETE /v1/tags/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/tags/list.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/tags/list.mdx index dfb16c47e..02efdd34f 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/tags/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/tags/list.mdx @@ -12,7 +12,7 @@ List all tags with optional filtering and pagination. ## Query Parameters - Filter by parent classification fully qualified name (e.g., `Certification`). + Filter by parent classification fully qualified name, for example `Certification`. @@ -47,44 +47,46 @@ configure( # List first page tags = Tags.list(limit=50) -for t in tags.data: - print(f"{t.fullyQualifiedName}") +for t in tags.entities: + print(f"{t.fullyQualifiedName.root}") # List all with auto-pagination for t in Tags.list_all(): - print(f"{t.fullyQualifiedName}") + print(f"{t.fullyQualifiedName.root}") # Filter by classification tags = Tags.list( - parent="Certification", + filters={"parent": "Certification"}, fields=["owners", "children"], limit=50 ) -for t in tags.data: - print(f"{t.fullyQualifiedName}") +for t in tags.entities: + print(f"{t.fullyQualifiedName.root}") if t.style: - print(f" Color: {t.style.get('color')}") + print(f" Color: {t.style.color}") ``` ```java GET /v1/tags -import static org.openmetadata.sdk.fluent.Tags.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Tags.list() - .limit(50) - .execute(); - -for (var t : result.getData()) { - System.out.println(t.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.tags().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by classification with fields -var result = Tags.list() - .parent("Certification") - .fields("owners", "children") - .limit(50) - .execute(); +var filtered = new ListParams() + .addFilter("parent", "Certification") + .setFields("owners,children") + .setLimit(50); +var filteredPage = client.tags().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); +} ``` ```bash GET /v1/tags diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/tags/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/tags/retrieve.mdx index d6a5cf81e..7bcc4709c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/tags/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/tags/retrieve.mdx @@ -16,7 +16,7 @@ Get a single tag by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `owners,children`). + Comma-separated list of fields to include, for example `owners,children`. @@ -28,7 +28,7 @@ Get a single tag by its unique ID or fully qualified name. Use `GET /v1/tags/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the tag (e.g., `Certification.Bronze`). + Fully qualified name of the tag, for example `Certification.Bronze`. @@ -51,7 +51,7 @@ configure( # Get by ID tag = Tags.retrieve("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") -print(f"{tag.fullyQualifiedName}: {tag.description}") +print(f"{tag.fullyQualifiedName.root}: {getattr(tag.description, 'root', tag.description)}") # Get by ID with fields tag = Tags.retrieve( @@ -70,22 +70,21 @@ tag = Tags.retrieve_by_name( ``` ```java GET /v1/tags/{id} -import static org.openmetadata.sdk.fluent.Tags.*; - -// Get by ID -var tag = Tags.retrieve("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); +// client is an initialized OpenMetadataClient. +var tag = client.tags().get("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); // Get by ID with fields -var tag = Tags.retrieve( +var tagWithFields = client.tags().get( "68ec158c-5f5e-4277-8a19-5e9e0cd5294f", - "owners,children" -); + "owners,children"); // Get by fully qualified name -var tag = Tags.retrieveByName("Certification.Bronze"); +var tagByName = client.tags().getByName("Certification.Bronze"); // Get by name with fields -var tag = Tags.retrieveByName("Certification.Bronze", "owners,children"); +var tagByNameWithFields = client.tags().getByName( + "Certification.Bronze", + "owners,children"); ``` ```bash GET /v1/tags/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/tags/update.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/tags/update.mdx index 68105a8b8..2a4131dc6 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/tags/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/tags/update.mdx @@ -20,7 +20,7 @@ Update a tag's properties using JSON Merge Patch. You can update by ID or by ful Use `PATCH /v1/tags/name/{fqn}` to update by fully qualified name. - Fully qualified name of the tag (e.g., `Certification.Bronze`). + Fully qualified name of the tag, for example `Certification.Bronze`. ## Body Parameters @@ -40,7 +40,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Hex color code (e.g., `#C08320`). + Hex color code, for example `#C08320`. @@ -58,7 +58,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -79,16 +79,16 @@ tag.description = "Updated: Bronze level certification for data assets" tag.style = {"color": "#D4A017"} updated = Tags.update(tag) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/tags/{id} -import static org.openmetadata.sdk.fluent.Tags.*; - -// Retrieve, modify, and update -var tag = Tags.retrieve("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); +// client is an initialized OpenMetadataClient. +var tagId = "68ec158c-5f5e-4277-8a19-5e9e0cd5294f"; +var tag = client.tags().get(tagId); tag.setDescription("Updated: Bronze level certification for data assets"); -var updated = Tags.update(tag); + +var updated = client.tags().update(tagId, tag); ``` ```bash PATCH /v1/tags/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/governance/tags/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/governance/tags/versions.mdx index 3b7fbfaa0..63a5e4474 100644 --- a/v2.1.x-SNAPSHOT/api-reference/governance/tags/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/governance/tags/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/tags/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/tags/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Tags @@ -40,31 +42,29 @@ configure( # List all versions versions = Tags.get_versions("68ec158c-5f5e-4277-8a19-5e9e0cd5294f") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version tag_v1 = Tags.get_specific_version( "68ec158c-5f5e-4277-8a19-5e9e0cd5294f", "0.1" ) -print(f"Original description: {tag_v1.description}") +print(f"Original description: {getattr(tag_v1.description, 'root', tag_v1.description)}") ``` ```java GET /v1/tags/{id}/versions -import static org.openmetadata.sdk.fluent.Tags.*; +// client is an initialized OpenMetadataClient. +var id = "68ec158c-5f5e-4277-8a19-5e9e0cd5294f"; // List all versions -var history = Tags.getVersions("68ec158c-5f5e-4277-8a19-5e9e0cd5294f"); - +var history = client.tags().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Tags.getSpecificVersion( - "68ec158c-5f5e-4277-8a19-5e9e0cd5294f", - 0.1 -); +var v1 = client.tags().getVersion(id, 0.1); System.out.println("Description: " + v1.getDescription()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/lineage/export.mdx b/v2.1.x-SNAPSHOT/api-reference/lineage/export.mdx index 0c9822e2d..ca38ffdca 100644 --- a/v2.1.x-SNAPSHOT/api-reference/lineage/export.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/lineage/export.mdx @@ -12,7 +12,7 @@ Export the lineage graph for a given entity as a CSV file. Useful for auditing, ## Query Parameters - Fully qualified name of the entity to export lineage for (e.g., `sample_data.ecommerce_db.shopify.dim_customer`). + Fully qualified name of the entity to export lineage for, for example `sample_data.ecommerce_db.shopify.dim_customer`. @@ -29,21 +29,24 @@ Export the lineage graph for a given entity as a CSV file. Useful for auditing, ```python GET /v1/lineage/export -from metadata.sdk import configure, get_client +from urllib.parse import urlencode + +from metadata.sdk import client, configure configure( host="https://your-company.open-metadata.org/api", jwt_token="your-jwt-token" ) -client = get_client() +rest = client().ometa.client # Export lineage as CSV -response = client.get("/lineage/export", params={ +params = urlencode({ "fqn": "sample_data.ecommerce_db.shopify.dim_customer", "type": "table", "upstreamDepth": 3, "downstreamDepth": 2, }) +response = rest.get(f"/lineage/export?{params}") print(response.text) ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/pagination.mdx b/v2.1.x-SNAPSHOT/api-reference/pagination.mdx index 893e2dbdf..6b8586269 100644 --- a/v2.1.x-SNAPSHOT/api-reference/pagination.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/pagination.mdx @@ -124,25 +124,23 @@ if first_page.paging.after: ``` ```java Basic Pagination -import org.openmetadata.client.api.TablesApi; -import org.openmetadata.client.model.TableList; +import org.openmetadata.sdk.models.ListParams; -TablesApi tablesApi = client.buildClient(TablesApi.class); +// client is an initialized OpenMetadataClient. // Get first page -TableList firstPage = tablesApi.listTables(null, 20, null, null, null); +var firstPage = client.tables().list(new ListParams().setLimit(20)); System.out.println("Total tables: " + firstPage.getPaging().getTotal()); -for (Table table : firstPage.getData()) { +for (var table : firstPage.getData()) { System.out.println(table.getFullyQualifiedName()); } // Get next page if (firstPage.getPaging().getAfter() != null) { - TableList nextPage = tablesApi.listTables( - null, 20, null, firstPage.getPaging().getAfter(), null - ); - for (Table table : nextPage.getData()) { + var nextPage = client.tables().list( + new ListParams().setLimit(20).setAfter(firstPage.getPaging().getAfter())); + for (var table : nextPage.getData()) { System.out.println(table.getFullyQualifiedName()); } } @@ -200,15 +198,20 @@ for table in metadata.list_all_entities(entity=Table, limit=100): ``` ```java Iterating Results -import org.openmetadata.client.api.TablesApi; +import org.openmetadata.sdk.models.ListParams; + +// client is an initialized OpenMetadataClient. -TablesApi tablesApi = client.buildClient(TablesApi.class); String afterCursor = null; do { - TableList page = tablesApi.listTables(null, 100, null, afterCursor, null); + var params = new ListParams().setLimit(100); + if (afterCursor != null) { + params.setAfter(afterCursor); + } + var page = client.tables().list(params); - for (Table table : page.getData()) { + for (var table : page.getData()) { System.out.println(table.getFullyQualifiedName()); // Process each table... } diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/ai-sdk.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/ai-sdk.mdx index 1264c65b6..29274c369 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/ai-sdk.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/ai-sdk.mdx @@ -95,7 +95,7 @@ const client = new AISdk({ ```java Java import io.openmetadata.ai.AISdk; -AISdk client = new AISdk.Builder() +AISdk client = AISdk.builder() .host("https://your-openmetadata-instance.com") .token("your-bot-jwt-token") .build(); diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/go-api-methods.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/go-api-methods.mdx index 44a19ed8f..30f29a926 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/go-api-methods.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/go-api-methods.mdx @@ -5,16 +5,15 @@ sidebarTitle: API Methods # Go SDK - API Methods -Once you have instantiated a `Rest` object you can call any of the following methods to perform operations against the OpenMetadata API. +Once you have created a `Client`, call the following methods on any of its services to perform operations against the OpenMetadata API. Examples of services are `client.Tables`, `client.Databases`, and `client.Users`. The examples below use `client.Tables`. They assume `ctx` is a `context.Background()` and that you created `client` as shown in [Go SDK](/v2.1.x-SNAPSHOT/api-reference/sdk/go). -### `Get` method +### `List` Method **Method signature** ```go -func (rest Rest) Get( - path string, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) List( + ctx context.Context, + params *ListTablesParams, +) iter.Seq2[Table, error] ``` **Example** @@ -23,21 +22,22 @@ func (rest Rest) Get( ... func main() { ... - path := "tables" - body, err := rest.Get(path, nil, nil, nil) + for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Name) + } } ``` +`List` fetches the next page of results for you as you loop, so you don't need to handle paging yourself. -### `Post` method +### `GetByID` and `GetByName` Methods **Method signature** ```go -func (rest Rest) Post( - path string, - data map[string]interface{}, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) GetByID(ctx context.Context, id string, params *GetTableByIDParams) (*Table, error) +func (s *TableService) GetByName(ctx context.Context, fqn string, params *GetTableByFQNParams) (*Table, error) ``` **Example** @@ -46,34 +46,45 @@ func (rest Rest) Post( ... func main() { ... - path := "tables" - data := map[string]interface{}{ - "name": "goClientTestTable", - "databaseSchema": "sample_data.ecommerce_db.shopify", - "columns": []map[string]interface{}{ - { - "name": "columnOne", - "dataType": "NUMBER", - }, - { - "name": "columnTwo", - "dataType": "NUMBER", - }, + table, err := client.Tables.GetByName(ctx, "sample_data.ecommerce_db.shopify.dim_customer", nil) + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Id) +} +``` + +### `Create` Method +**Method signature** +```go +func (s *TableService) Create(ctx context.Context, body *CreateTable) (*Table, error) +``` + +**Example** +```go +// main.go +... +func main() { + ... + table, err := client.Tables.Create(ctx, &ometa.CreateTable{ + Name: "goClientTestTable", + DatabaseSchema: "sample_data.ecommerce_db.shopify", + Columns: []ometa.Column{ + {Name: "columnOne", DataType: ometa.ColumnDataTypeNUMBER}, + {Name: "columnTwo", DataType: ometa.ColumnDataTypeNUMBER}, }, + }) + if err != nil { + log.Fatal(err) } - body, err := rest.Post(path, data, nil, nil, nil) + fmt.Println(table.Id) } ``` -### `Put` method +### `CreateOrUpdate` Method **Method signature** ```go -func (rest Rest) Put( - path string, - data map[string]interface{}, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) CreateOrUpdate(ctx context.Context, body *CreateTable) (*Table, error) ``` **Example** @@ -82,38 +93,26 @@ func (rest Rest) Put( ... func main() { ... - path := "tables" - data := map[string]interface{}{ - "name": "goClientTestTable", - "databaseSchema": "sample_data.ecommerce_db.shopify", - "columns": []map[string]interface{}{ - { - "name": "columnOne", - "dataType": "NUMBER", - }, - { - "name": "columnTwo", - "dataType": "NUMBER", - }, - { - "name": "columnThree", - "dataType": "NUMBER", - }, - }, - } - body, err := rest.Put(path, data, nil, nil, nil) + table, err := client.Tables.CreateOrUpdate(ctx, &ometa.CreateTable{ + Name: "goClientTestTable", + DatabaseSchema: "sample_data.ecommerce_db.shopify", + Columns: []ometa.Column{ + {Name: "columnOne", DataType: ometa.ColumnDataTypeNUMBER}, + {Name: "columnTwo", DataType: ometa.ColumnDataTypeNUMBER}, + {Name: "columnThree", DataType: ometa.ColumnDataTypeNUMBER}, + }, + }) + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Id) } ``` -### `Patch` method +### `Patch` Method **Method signature** ```go -func (rest Rest) Patch( - path string, - data []map[string]interface{}, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) Patch(ctx context.Context, id string, ops []JSONPatchOp) (*Table, error) ``` **Example** @@ -122,27 +121,22 @@ func (rest Rest) Patch( ... func main() { ... - path := "tables" - patchPath := fmt.Sprintf("tables/%s", id) - data := []map[string]interface{}{ - { - "op": "add", - "path": "/description", - "value": "This is a test table", - }, - } - body, err := rest.Patch(patchPath, data, nil, nil, nil) + id := table.Id.String() + updated, err := client.Tables.Patch(ctx, id, []ometa.JSONPatchOp{ + {Op: "add", Path: "/description", Value: "This is a test table"}, + }) + if err != nil { + log.Fatal(err) + } + fmt.Println(*updated.Description) } ``` -### `Delete` method +### `Delete` and `DeleteByName` Methods **Method signature** ```go -func (rest Rest) Delete( - path string, - header http.Header, - extraHeader map[string][]string, - queryParams map[string]string) (map[string]any, error) +func (s *TableService) Delete(ctx context.Context, id string, params *DeleteTableParams) error +func (s *TableService) DeleteByName(ctx context.Context, fqn string, params *DeleteTable1Params) error ``` **Example** @@ -151,11 +145,12 @@ func (rest Rest) Delete( ... func main() { ... - path := fmt.Sprintf("tables/%s", id) - queryParams := map[string]string{ - "hardDelete": "true", - "recursive": "true", - } - rest.Delete(path, nil, nil, queryParams) + err := client.Tables.Delete(ctx, table.Id.String(), &ometa.DeleteTableParams{ + HardDelete: ometa.Bool(true), + Recursive: ometa.Bool(true), + }) + if err != nil { + log.Fatal(err) + } } ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/go.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/go.mdx index 3accc2fc8..74cf0c333 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/go.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/go.mdx @@ -18,49 +18,41 @@ You can add the module to your application with the below command go get github.com/open-metadata/openmetadata-sdk/openmetadata-go-client ``` -## Establish OpenMetadata Server Connection +## Create a Client -To create OpenMetadata Gateway, you will need to establish a connection with *OpenMetadata Server*. The following inputs will be needed: -* `BaseURL`: The url on which your instance of OpenMetadata is up and running (include the port if you need to e.g. `http://localhost:8585`). -* `APIVersion`: pass an empty string -- this will be `v1` for now. -* `Retry`: number of time the request should retry if the status code returned is in `RetryCodes`. Use `0` to use the default value -* `RetryWait`: number of second to wait betwee retries. Pass 0 to use the default value -* `RetryCodes`: HTTP status that will trigger a retry. Pass `nil` to use the default -* `AuthTokenMode`: defaults to `Bearer` -* `AccessToken`: JWT token use to authenticate the request +To talk to OpenMetadata, create a `Client` with the server address and, optionally, settings passed as options: +* `baseURL` (first argument): the address where your OpenMetadata server is running, without the `/api` suffix (include the port if you need to, for example `http://localhost:8585`). The client adds `/api/v1` itself. +* `WithToken(token)`: the JWT token used to authenticate every request. +* `WithAPIVersion(v)`: the API version to call. Defaults to `v1`, so you normally don't set it. +* `WithRetry(count, wait)`: how many times to retry a request, and how long to wait between retries. Defaults to 3 retries, 30 seconds apart. The client retries a request when the server answers `429` or `504`. +* `WithHTTPClient(c)`: use your own `*http.Client`, for example to set a proxy or custom TLS settings. ```go // main.go package main import ( + "context" + "fmt" + "log" + "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" ) func main() { - restConfig := ometa.NewRestConfig( + ctx := context.Background() + client := ometa.NewClient( "http://localhost:8585", - "", // APIVersion - 0, // Retry -> defaults to 3 - 0, // RetryWait -> defaults to 30 seconds - nil, // RetryCodes -> defaults to [429, 504] - "JWTToken", + ometa.WithToken(""), ) -} -``` - - -## Create OpenMetadata Gateway - -Once the connection details are provided, you can create an OpenMetadata Gateway -using the following piece of code. -```go -// main.go -... - -func main() { - ... - rest := ometa.NewRest(restConfig) + for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Name) + } } ``` + +The client has one service for each entity type, such as `client.Tables`, `client.Databases`, and `client.Users`. For more information about the methods every service provides, see [Go SDK - API Methods](/v2.1.x-SNAPSHOT/api-reference/sdk/go-api-methods). diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/java.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/java.mdx index 727aa1d18..a53d0e58c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/java.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/java.mdx @@ -24,204 +24,148 @@ You can add the below Maven Dependency for the OpenMetadata Java SDK. ``` -## Establish OpenMetadata Server Connection +## Connect to the OpenMetadata Server -To create OpenMetadata Gateway, you will need to establish a connection with *OpenMetadata Server*. The following -inputs will be needed for the same. -* Host Port: The url on which your instance of OpenMetadata is up and running. -* ApiVersion: The value will be "v1". -* Auth Provider: Provide the auth provider with which you need to configure. -* Security Config: Provide the config for the selected auth provider. +To connect to your OpenMetadata server, you need: -```java -OpenMetadataConnection server = new OpenMetadataConnection(); -server.setHostPort("http://localhost:{port}}/api"); -server.setApiVersion("v1"); -server.setAuthProvider(OpenMetadataConnection.AuthProvider.{auth_provider}); -server.setSecurityConfig({security_client_config}); -``` - -## Create OpenMetadata Gateway - -Once the connection details are provided, you can create an OpenMetadata Gateway -using the following piece of code. +* Server URL: The URL where your OpenMetadata instance is running, ending in `/api`. For example, `http://localhost:8585/api`. +* Access token: A JSON Web Token (JWT) for a user or bot. See [Authentication](/v2.1.x-SNAPSHOT/api-reference/authentication) to learn how to get one. ```java -// OpenMetadata Gateway -OpenMetadata openMetadataGateway = new OpenMetadata(server); -``` +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -## Use Java SDK without Authentication -To use the Java SDK without any authentication, you can use `NoOpAuthenticationProvider.java`. \ +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .build(); -```java -NoOpAuthenticationProvider noOpAuthenticationProvider = new NoOpAuthenticationProvider(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` -Establish the [OpenMetadata Server Connection](#establish-openmetadata-server-connection) and provide `noOpAuthenticationProvider` in the config. +Tune the connection with these options. Timeouts are in milliseconds, and `header` adds a custom header to every request: ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.NO_AUTH); +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .connectTimeout(10000) + .readTimeout(30000) + .header("X-Request-Source", "my-app") + .build(); ``` -## Use Java SDK with Authentication. +## Authenticate with a JWT Token -The OpenMetadata Java SDK supports several auth providers: -* [Google](#google) -* [Okta](#okta) -* [Auth0](#auth0) -* [Azure](#azure) -* [OpenMetadata](#openmetadata) +The Java SDK authenticates with a JWT access token that you pass to `accessToken(...)`. This is the same for every sign-in method on your OpenMetadata server, including Google, Okta, Auth0, Azure, and custom OpenID Connect (OIDC). Generate a bot token or a personal access token in OpenMetadata and use it here. -Apart from the above mentioned auth providers, OpenMetadata Java SDK also supports [Custom OIDC](#custom-oidc). +If your server doesn't require authentication, leave out `accessToken(...)`. -### Google -To set up Google as the auth provider, the following details are required: -* Secret Key: Pass the JSON file generated in [Create Service Account](/v2.1.x-SNAPSHOT/deployment/security/google) as the secretKey. +## Use the Fluent API -```java -GoogleSSOClientConfig googleSSOClientConfig = new GoogleSSOClientConfig(); -ssoConfig.setAudience("https://www.googleapis.com/oauth2/v4/token"); -ssoConfig.setSecretKey("{secret_key.json}"); -``` +The fluent classes, such as `Tables`, `Users`, and `Teams`, work with a default client. Register your client once with `OM.init`, and the fluent classes use it: -Provide the Google config while creating the [server connection](#establish-openmetadata-server-connection). ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.GOOGLE); -server.setSecurityConfig(googleSSOClientConfig); +import org.openmetadata.sdk.OM; +import org.openmetadata.sdk.fluent.Tables; -``` +OM.init(client); -### Okta -To set up Okta as the auth provider, the following details should be provided: -* Client ID: Provide the client ID for the service application -* Org URL: It is the same as the ISSUER_URL with v1/token. It is recommended to use a separate authorization server for different applications, rather than using the default authorization server. -* Private Key: Use the Public/Private Key Pair that was generated while [Creating the Service Application](/v2.1.x-SNAPSHOT/deployment/security/okta#okta-sso). When copy-pasting the keys ensure that there are no additional codes and that it is a JSON compatible string. -* Email: Enter the email address -* Scopes: Add the details of the scope created in the Authorization Server. Enter the name of the default scope created. +// Find a table by its fully qualified name +var table = Tables.findByName("mysql-prod.employees.public.employees") + .includeOwners() + .includeTags() + .fetch() + .get(); -```java -OktaSSOClientConfig oktaSSOClientConfig = new OktaSSOClientConfig(); -oktaSSOClientConfig.setClientId("{client_id}"); -oktaSSOClientConfig.setOrgURL("{org_url}/v1/token"); -oktaSSOClientConfig.setPrivateKey("{public/private keypair}"); -oktaSSOClientConfig.setEmail("{email}"); -oktaSSOClientConfig.setScopes({scope_list}); +// Update its description +Tables.findByName("mysql-prod.employees.public.employees") + .fetch() + .withDescription("Updated description") + .save(); ``` -Provide the Okta config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OKTA); -server.setSecurityConfig(oktaSSOClientConfig); -``` +## Use the Service Clients -### Auth0 -To set up Auth0 as the auth provider, the following details are required: -* Client ID: Provide the client ID for the service application -* Secret Key: Provide the client secret. -* Domain: Provide the Auth0 domain. For example `test.us.auth0.com` +Every entity type has a service on the client, such as `client.tables()`, `client.users()`, and `client.dashboards()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. Below are some examples: ```java -Auth0SSOClientConfig auth0SSOClientConfig = new Auth0SSOClientConfig(); -auth0SSOClientConfig.setClientId("{client_id}"); -auth0SSOClientConfig.setSecretKey("{secret_key}"); -auth0SSOClientConfig.setDomain("{domain}"); -``` -Provide the Auth0 config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AUTH_0); -server.setSecurityConfig(auth0SSOClientConfig); -``` +import org.openmetadata.sdk.models.ListParams; -### Azure -To set up Azure as the auth provider, the following details should be provided: -* Client ID: The Application (Client) ID is displayed in the Overview section of the registered application. -* Client Secret: The clientSecret can be accessed from the Certificates & secret section of the application. -* Authority: Use your Microsoft Entra tenant authority. See [Microsoft's OpenID Connect documentation](https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc) for the endpoint format. -* Scopes: Add the details of the scope created. +// Tables +var tables = client.tables().list(new ListParams().setLimit(10)); +for (var table : tables.getData()) { + System.out.println(table.getFullyQualifiedName()); +} -```java -AzureSSOClientConfig azureSSOClientConfig = new AzureSSOClientConfig(); -azureSSOClientConfig.setClientId("{client_id}"); -azureSSOClientConfig.setClientSecret("{client_secret}"); -azureSSOClientConfig.setAuthority("{authority}"); -azureSSOClientConfig.setScopes({scope_list}); -``` -Provide the Azure config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AZURE); -server.setSecurityConfig(azureSSOClientConfig); +// Users +var users = client.users().list(new ListParams().setLimit(10)); + +// Dashboards +var dashboards = client.dashboards().list(new ListParams().setLimit(10)); ``` -### OpenMetadata -To set up OpenMetadata as the auth provider, the following details should be provided: -* JWT Token: Provide the JWT Token. For example `eyJraWQiOiJHYjM4OWEtOWY3Ni1nZGpzLWE5Mmo....XN0aW9uLWJvdEBvcGVubWV0YWRhdGEub3JnIn0.Ku_FHGIS3Id3ARusMaXZDYKcq...Ztap9KDU7nZilNT2Bq-o75aIsgKKmtSuVdBTzpFK8aLGLmRp_8J007t-kpcjIW7Qf0l4...dGb0QqhoZin0JA` +The following examples show how to call an API: + +* Create a table ```java -OpenMetadataJWTClientConfig openMetadataJWTClientConfig = new OpenMetadataJWTClientConfig(); -openMetadataJWTClientConfig.setJwtToken("{jwt_token}"); -``` -Provide the OpenMetadata config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OPENMETADATA); -server.setSecurityConfig(openMetadataJWTClientConfig); -``` +import java.util.List; +import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; -### Custom OIDC -To set up Custom auth provider. The following details are required: -* Client ID: Provide the client ID of the preferred auth provider -* Client Secret: Provide the client secret of your preferred auth provider -* Token Endpoint: Provide the token endpoint of your preferred auth provider +CreateTable request = new CreateTable() + .withName("orders") + .withDatabaseSchema("mysql-prod.employees.public") + .withDescription("Orders placed by customers") + .withColumns(List.of( + new Column() + .withName("order_id") + .withDataType(ColumnDataType.BIGINT) + .withDescription("Primary key"), + new Column() + .withName("status") + .withDataType(ColumnDataType.VARCHAR) + .withDataLength(50))); -```java -CustomOIDCSSOClientConfig customOIDCSSOClientConfig = new CustomOIDCSSOClientConfig(); -config.setClientId("{client_id}"); -config.setSecretKey("{client_secret}"); -config.setTokenEndpoint("{token_endpoint}"); +var table = client.tables().create(request); ``` -Provide the custom auth provider config while creating the [server connection](#establish-openmetadata-server-connection). +* Get a table by fully qualified name + ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.CUSTOM_OIDC); -server.setSecurityConfig(customOIDCSSOClientConfig); +var table = client.tables().getByName("mysql-prod.employees.public.employees", "columns,owners"); ``` -## How to Use APIs Using the Java SDK -You can use an API from the [OpenMetadata Gateway](#create-openmetadata-gateway). -Using OpenMetadata Gateway, you will need to build the client by providing the `class` of the respected API. -Below are some examples: +* Search + ```java -// Dashboards API -DashboardsApi dashboardApi = openMetadataGateway.buildClient(DashboardsApi.class); +String response = client.search() + .query("customer") + .index("table_search_index") + .size(10) + .execute(); +``` -// Tables API -TablesApi tablesApiClient = openMetadataGateway.buildClient(TablesApi.class); +The search call returns the raw JSON response from the server as a string. -// Users API -UsersApi usersApi = openMetadataGateway.buildClient(UsersApi.class); +## Handle Errors -// Locations API -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -``` +When the server returns an error, the SDK throws an `OpenMetadataException`. Use `getStatusCode()` to see which error it was: -Please refer to the examples to access an API: -* Tables API ```java -TablesApi tablesApi = openMetadataGateway.buildClient(TablesApi.class); -tablesApi.addLocationToTable("{table_id}", "{location_id}"); -``` -* Location API -```java -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -CreateLocation createLocation = new CreateLocation(); -Location location = locationsApi.createLocation(createLocation); -``` +import org.openmetadata.sdk.exceptions.OpenMetadataException; -* Elastic Search API -```java -ElasticSearchApi esApi = openMetadataGateway.buildClient(ElasticSearchApi.class); -Response response = esApi.searchEntitiesWithQuery("", "pipeline_search_index", false, 0, 0, null, null, true, "{\"query\":{\"bool\":{}}}", null, false, null ); -String data = IOUtils.toString(response.body().asInputStream(), Charsets.UTF_8); +try { + var table = client.tables().getByName("mysql-prod.employees.public.missing"); +} catch (OpenMetadataException e) { + if (e.getStatusCode() == 404) { + System.out.println("Table not found"); + } else { + System.out.println("Request failed: " + e.getMessage()); + } +} ``` ## More examples diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/java/info.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/java/info.mdx index b81f01cc0..07c3b9914 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/java/info.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/java/info.mdx @@ -6,7 +6,7 @@ sidebarTitle: Java SDK Info # Java SDK -The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers comprehensive support for entity management, authentication, and integration with enterprise Java applications. +The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers support for entity management, search, lineage, and authentication with a JWT token. ## Installation @@ -35,85 +35,87 @@ implementation 'org.open-metadata:openmetadata-sdk:2.0.5' ### Basic Connection ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; -import org.openmetadata.client.auth.BasicAuthProvider; - -// Create client with basic authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new BasicAuthProvider("admin", "admin")) +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.network.HttpMethod; + +// Create a client with a JWT token +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") .build(); -// Health check -if (client.healthCheck()) { - System.out.println("Successfully connected to OpenMetadata!"); -} -``` - -### JWT Authentication - -```java -import org.openmetadata.client.auth.JWTAuthProvider; +OpenMetadataClient client = new OpenMetadataClient(config); -// Create client with JWT authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new JWTAuthProvider("your-jwt-token")) - .build(); +// Check the connection by reading the server version +String version = client.getHttpClient() + .executeForString(HttpMethod.GET, "/v1/system/version", null); +System.out.println("Connected to OpenMetadata: " + version); ``` +For more information about getting a token, see [Authentication](/v2.1.x-SNAPSHOT/api-reference/authentication). + ## Core Functionality ### Working with Entities +Every entity type has a service on the client, such as `client.databaseServices()`, `client.tables()`, and `client.users()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. + #### Database Services ```java -import org.openmetadata.schema.entity.services.DatabaseService; import org.openmetadata.schema.api.services.CreateDatabaseService; +import org.openmetadata.schema.api.services.DatabaseConnection; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.services.connections.database.MysqlConnection; +import org.openmetadata.sdk.models.ListParams; -// List all database services -List services = client.listDatabaseServices(); -System.out.println("Found " + services.size() + " database services"); +// List database services +var services = client.databaseServices().list(new ListParams().setLimit(50)); +System.out.println("Found " + services.getData().size() + " database services"); // Get specific service by name -DatabaseService service = client.getDatabaseServiceByName("mysql-prod"); +DatabaseService service = client.databaseServices().getByName("mysql-prod"); // Create new database service CreateDatabaseService createRequest = new CreateDatabaseService() .withName("new-mysql-service") - .withServiceType(DatabaseServiceType.MYSQL) - .withDescription("Production MySQL database"); - -DatabaseService newService = client.createDatabaseService(createRequest); + .withServiceType(CreateDatabaseService.DatabaseServiceType.Mysql) + .withDescription("Production MySQL database") + .withConnection(new DatabaseConnection().withConfig( + new MysqlConnection() + .withHostPort("localhost:3306") + .withUsername("openmetadata_user"))); + +DatabaseService newService = client.databaseServices().create(createRequest); ``` #### Tables ```java -import org.openmetadata.schema.entity.data.Table; +import java.util.List; import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; +import org.openmetadata.sdk.models.ListParams; // Get table by fully qualified name -Table table = client.getTableByName("mysql-prod.employees.employees"); -if (table != null) { - System.out.println("Table: " + table.getName()); - System.out.println("Columns: " + table.getColumns().size()); -} +Table table = client.tables().getByName("mysql-prod.employees.public.employees", "columns"); +System.out.println("Table: " + table.getName()); +System.out.println("Columns: " + table.getColumns().size()); -// List tables with pagination -EntityList
tables = client.listTables( - 10, // limit - null, // after cursor - "mysql-prod" // service filter -); +// List tables in a schema with pagination +var tables = client.tables().list( + new ListParams() + .setLimit(10) + .addFilter("databaseSchema", "mysql-prod.employees.public")); // Create table CreateTable createTable = new CreateTable() .withName("new_table") - .withDatabaseSchema("mysql-prod.employees") - .withColumns(Arrays.asList( + .withDatabaseSchema("mysql-prod.employees.public") + .withColumns(List.of( new Column() .withName("id") .withDataType(ColumnDataType.BIGINT) @@ -125,7 +127,7 @@ CreateTable createTable = new CreateTable() .withDescription("Employee name") )); -Table newTable = client.createTable(createTable); +Table newTable = client.tables().create(createTable); ``` ### Entity Operations @@ -133,111 +135,83 @@ Table newTable = client.createTable(createTable); #### CRUD Operations ```java -// Create or Update -DatabaseService service = client.createOrUpdateDatabaseService(createRequest); +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.network.HttpMethod; + +// Create or update a table +Table table = client.tables().createOrUpdate(createTable); + +// Create or update a database service +DatabaseService service = client.getHttpClient().execute( + HttpMethod.PUT, "/v1/services/databaseServices", createRequest, DatabaseService.class); // Get by ID -UUID serviceId = UUID.fromString("service-uuid-here"); -DatabaseService service = client.getDatabaseServiceById(serviceId); +UUID serviceId = service.getId(); +DatabaseService sameService = client.databaseServices().get(serviceId); // Delete -client.deleteDatabaseService(serviceId, false); // soft delete -client.deleteDatabaseService(serviceId, true); // hard delete +client.databaseServices().delete(serviceId.toString()); // soft delete +client.databaseServices().delete(serviceId.toString(), Map.of("hardDelete", "true")); // hard delete ``` #### Search and Filtering ```java -// Search tables -SearchRequest searchRequest = new SearchRequest() - .withQuery("customer") - .withEntityTypes(Arrays.asList("table")) - .withSize(50); - -SearchResponse results = client.search(searchRequest); -for (SearchHit hit : results.getHits()) { - System.out.println("Found: " + hit.getDisplayName()); -} +import org.openmetadata.sdk.models.ListParams; + +// Search tables. The response is the raw JSON from the server. +String results = client.search() + .query("customer") + .index("table_search_index") + .size(50) + .execute(); +System.out.println(results); // Advanced filtering -EntityList
customerTables = client.listTables( - 100, - null, - Map.of( - "service", "mysql-prod", - "database", "ecommerce" - ) -); +var customerTables = client.tables().list( + new ListParams() + .setLimit(100) + .addFilter("database", "mysql-prod.ecommerce")); ``` ## Advanced Features -### Authentication Providers - -#### Custom Authentication - -```java -import org.openmetadata.client.auth.AuthProvider; - -public class CustomAuthProvider implements AuthProvider { - private String customToken; - - public CustomAuthProvider(String token) { - this.customToken = token; - } - - @Override - public String getAuthToken() { - return "Bearer " + customToken; - } - - @Override - public void refresh() { - // Implement token refresh logic - } -} - -// Use custom auth provider -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(new CustomAuthProvider("custom-token")) - .build(); -``` +### Authentication -#### OAuth 2.0 Integration +The Java SDK authenticates with a JWT access token. When your token changes, create a new client with the new token: ```java -import org.openmetadata.client.auth.OAuth2AuthProvider; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -OAuth2AuthProvider authProvider = OAuth2AuthProvider.builder() - .clientId("your-client-id") - .clientSecret("your-client-secret") - .tokenUrl("https://auth.provider.com/oauth/token") - .scopes(Arrays.asList("read", "write")) - .build(); +String newToken = "your-new-jwt-token"; -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(authProvider) - .build(); +OpenMetadataClient client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl("https://your-instance.com/api") + .accessToken(newToken) + .build()); ``` ### Error Handling ```java -import org.openmetadata.client.exception.OpenMetadataException; +import org.openmetadata.sdk.exceptions.OpenMetadataException; try { - Table table = client.getTableByName("non-existent-table"); + var table = client.tables().getByName("non-existent-table"); } catch (OpenMetadataException e) { - switch (e.getErrorCode()) { - case NOT_FOUND: + switch (e.getStatusCode()) { + case 404: System.out.println("Table not found"); break; - case UNAUTHORIZED: + case 401: System.out.println("Authentication failed"); break; - case FORBIDDEN: + case 403: System.out.println("Access denied"); break; default: @@ -248,15 +222,22 @@ try { ### Async Operations +The service methods are blocking. To run them in parallel, wrap them in a `CompletableFuture`: + ```java +import java.util.List; import java.util.concurrent.CompletableFuture; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.models.ListParams; -// Async client operations CompletableFuture> servicesFuture = - client.listDatabaseServicesAsync(); + CompletableFuture.supplyAsync( + () -> client.databaseServices().list(new ListParams().setLimit(50)).getData()); CompletableFuture
tableFuture = - client.getTableByNameAsync("mysql-prod.employees.employees"); + CompletableFuture.supplyAsync( + () -> client.tables().getByName("mysql-prod.employees.public.employees", "columns")); // Combine async operations CompletableFuture combinedFuture = CompletableFuture.allOf( @@ -280,39 +261,19 @@ CompletableFuture combinedFuture = CompletableFuture.allOf( ### Client Configuration ```java -import org.openmetadata.client.config.ClientConfig; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -ClientConfig config = ClientConfig.builder() - .connectionTimeout(30000) // 30 seconds +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .connectTimeout(30000) // 30 seconds .readTimeout(60000) // 60 seconds - .retryCount(3) // Retry failed requests 3 times - .enableLogging(true) // Enable request/response logging - .enableMetrics(true) // Enable client metrics - .userAgent("MyApp/1.0") // Custom user agent + .writeTimeout(60000) // 60 seconds + .header("User-Agent", "MyApp/1.0") // Custom header on every request .build(); -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(authProvider) - .config(config) - .build(); -``` - -### Connection Pooling - -```java -import org.openmetadata.client.config.ConnectionPoolConfig; - -ConnectionPoolConfig poolConfig = ConnectionPoolConfig.builder() - .maxTotal(100) // Maximum total connections - .maxPerRoute(20) // Maximum connections per route - .connectionTTL(300000) // Connection TTL in milliseconds - .validateAfterInactivity(10000) // Validate connections after 10s - .build(); - -ClientConfig config = ClientConfig.builder() - .connectionPoolConfig(poolConfig) - .build(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ## Common Use Cases @@ -320,15 +281,26 @@ ClientConfig config = ClientConfig.builder() ### Metadata Discovery ```java -// Discover all tables in a service -String serviceName = "mysql-prod"; +import java.util.ArrayList; +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + +// Discover all tables in a schema +String schemaName = "mysql-prod.employees.public"; List
allTables = new ArrayList<>(); String after = null; do { - EntityList
batch = client.listTables(100, after, serviceName); + var params = new ListParams() + .setLimit(100) + .addFilter("databaseSchema", schemaName); + if (after != null) { + params.setAfter(after); + } + var batch = client.tables().list(params); allTables.addAll(batch.getData()); - after = batch.getAfter(); + after = batch.getPaging().getAfter(); } while (after != null); System.out.println("Discovered " + allTables.size() + " tables"); @@ -337,17 +309,19 @@ System.out.println("Discovered " + allTables.size() + " tables"); ### Bulk Operations ```java +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + // Bulk update table descriptions -List
tables = client.listAllTablesInService("mysql-prod"); +List
tables = client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", "mysql-prod.employees.public")) + .getData(); for (Table table : tables) { if (table.getDescription() == null || table.getDescription().isEmpty()) { - CreateTable updateRequest = new CreateTable() - .withName(table.getName()) - .withDatabaseSchema(table.getDatabaseSchema().getFullyQualifiedName()) - .withDescription("Auto-generated description for " + table.getName()); - - client.createOrUpdateTable(updateRequest); + table.setDescription("Auto-generated description for " + table.getName()); + client.tables().update(table.getId().toString(), table); } } ``` @@ -355,87 +329,61 @@ for (Table table : tables) { ### Lineage Operations ```java -import org.openmetadata.schema.type.EntityLineage; - -// Get table lineage -EntityLineage lineage = client.getTableLineage( - "mysql-prod.employees.employees", - 1, // upstream depth - 1 // downstream depth +// Get table lineage as JSON (1 hop upstream, 1 hop downstream) +String lineage = client.lineage().getLineageByName( + "table", + "mysql-prod.employees.public.employees", + "1", // upstream depth + "1" // downstream depth ); -System.out.println("Upstream entities: " + lineage.getUpstreamEdges().size()); -System.out.println("Downstream entities: " + lineage.getDownstreamEdges().size()); +System.out.println(lineage); ``` -## Spring Boot Integration +For more information about the fluent API for lineage, see [Java SDK for Lineage](/v2.1.x-SNAPSHOT/api-reference/sdk/java/lineage). -### Configuration Class +## Use the Client in Your Application -```java -@Configuration -@EnableConfigurationProperties(OpenMetadataProperties.class) -public class OpenMetadataConfig { - - @Bean - public OpenMetadataClient openMetadataClient(OpenMetadataProperties properties) { - return OpenMetadataClient.builder() - .baseUrl(properties.getBaseUrl()) - .authProvider(new JWTAuthProvider(properties.getJwtToken())) - .build(); - } -} - -@ConfigurationProperties(prefix = "openmetadata") -@Data -public class OpenMetadataProperties { - private String baseUrl; - private String jwtToken; -} -``` - -### Service Layer +Create one `OpenMetadataClient` and share it across your application. If you use a framework such as Spring Boot, register the client as a singleton bean. ```java -@Service -public class MetadataService { +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.models.ListParams; - private final OpenMetadataClient client; +class MetadataService { - public MetadataService(OpenMetadataClient client) { - this.client = client; - } + private final OpenMetadataClient client; - public List
getTablesForService(String serviceName) { - return client.listAllTablesInService(serviceName); + public MetadataService(String baseUrl, String jwtToken) { + this.client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl(baseUrl) + .accessToken(jwtToken) + .build()); } - public Table createTable(CreateTableRequest request) { - CreateTable createTable = new CreateTable() - .withName(request.getName()) - .withDatabaseSchema(request.getSchemaFqn()) - .withColumns(request.getColumns()); - - return client.createTable(createTable); + public java.util.List getTablesForSchema(String schemaFqn) { + return client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", schemaFqn)) + .getData(); } } ``` ## Best Practices -1. **Resource Management**: Always close clients when done -2. **Connection Pooling**: Use connection pooling for high-throughput applications -3. **Error Handling**: Implement proper retry logic and error handling -4. **Authentication**: Use secure authentication methods in production -5. **Async Operations**: Use async methods for better performance in concurrent scenarios -6. **Pagination**: Always handle pagination for large datasets -7. **Caching**: Implement caching for frequently accessed entities +- **Reuse the client**: Create one client and share it instead of creating a new one per request. +- **Handle errors**: Catch `OpenMetadataException` and check the status code. +- **Protect authentication**: Keep your JWT token in a secret store, not in source code. +- **Use async operations**: Wrap calls in `CompletableFuture` for better performance in concurrent scenarios. +- **Handle pagination**: Always handle pagination for large datasets. +- **Cache entities**: Implement caching for frequently accessed entities. ## Performance Tips -- Use batch operations when possible -- Implement connection pooling for high-concurrency applications -- Cache frequently accessed metadata -- Use async operations for better throughput -- Specify only required fields when fetching entities -- Implement proper retry strategies with exponential backoff \ No newline at end of file +- Create one client and reuse it. +- Cache frequently accessed metadata. +- Run independent calls in parallel with `CompletableFuture`. +- Specify only required fields when fetching entities. +- Use filters to narrow lists before you read them. diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/java/lineage.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/java/lineage.mdx index 4ed1ded83..2a547fda2 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/java/lineage.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/java/lineage.mdx @@ -24,12 +24,15 @@ Before using the fluent API, initialize the client: ```java import org.openmetadata.sdk.api.Lineage; import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .jwtToken("") +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("") .build(); +OpenMetadataClient client = new OpenMetadataClient(config); + Lineage.setDefaultClient(client); ``` @@ -38,6 +41,8 @@ Lineage.setDefaultClient(client); Retrieve the lineage graph for an entity by type and ID: ```java +import org.openmetadata.sdk.api.Lineage; + // Get lineage with default depth (1 upstream, 1 downstream) Lineage.LineageGraph graph = Lineage.of("table", tableId).fetch(); @@ -47,9 +52,11 @@ String raw = graph.getRaw(); ### Custom Depth -Control how many hops upstream and downstream are returned: +Control how many hops upstream and downstream are returned. Use a depth of 3 or less, because the server rejects deeper requests: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageGraph graph = Lineage.of("table", tableId) .upstream(3) .downstream(2) @@ -59,14 +66,18 @@ Lineage.LineageGraph graph = Lineage.of("table", tableId) Or set both directions to the same value: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageGraph graph = Lineage.of("table", tableId) - .depth(5) + .depth(3) .fetch(); ``` ### Include Deleted Entities ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageGraph graph = Lineage.of("table", tableId) .includeDeleted(true) .fetch(); @@ -77,6 +88,8 @@ Lineage.LineageGraph graph = Lineage.of("table", tableId) Use `Lineage.connect()` to create an edge between two entities: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("dashboard", dashboardId) @@ -89,6 +102,8 @@ Lineage.LineageEdge edge = Lineage.connect() Map specific columns from the source entity to columns in the target entity: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .fromColumns("customer_id", "order_date") @@ -106,6 +121,8 @@ a `columnsLineage` array inside `lineageDetails`. Associate a pipeline entity that powers the transformation: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("table", targetTableId) @@ -119,6 +136,8 @@ Lineage.LineageEdge edge = Lineage.connect() Attach the SQL query driving the lineage: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .to("table", targetTableId) @@ -131,6 +150,8 @@ Lineage.LineageEdge edge = Lineage.connect() Combine all options: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.LineageEdge edge = Lineage.connect() .from("table", sourceTableId) .fromColumns("customer_id", "order_date") @@ -147,6 +168,8 @@ Lineage.LineageEdge edge = Lineage.connect() Remove a lineage edge between two entities: ```java +import org.openmetadata.sdk.api.Lineage; + Lineage.disconnect() .from("table", sourceTableId) .to("dashboard", dashboardId) @@ -158,6 +181,8 @@ Lineage.disconnect() Export the lineage graph for a given entity by its fully qualified name: ```java +import org.openmetadata.sdk.api.Lineage; + String csv = Lineage.export() .entity("table", "service.database.schema.my_table") .upstream(3) @@ -167,28 +192,37 @@ String csv = Lineage.export() ## Impact Analysis -Analyze which downstream (or upstream) entities are affected by changes to a given entity: +To find the entities affected by a change, fetch the lineage graph in one direction and read the entities from the raw JSON. The `nodes` array lists every entity in the graph. ### Downstream Impact ```java -Lineage.ImpactAnalysis impact = Lineage.impact() - .of("table", tableId) - .downstream() - .depth(3) - .analyze(); +import org.openmetadata.sdk.api.Lineage; -int totalImpacted = impact.getTotalImpactCount(); +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +Lineage.LineageGraph graph = Lineage.of("table", tableId) + .upstream(0) + .downstream(3) + .fetch(); + +JsonNode lineage = new ObjectMapper().readTree(graph.getRaw()); +for (JsonNode node : lineage.path("nodes")) { + System.out.println(node.path("type").asText() + ": " + node.path("fullyQualifiedName").asText()); +} +System.out.println("Impacted entities: " + lineage.path("nodes").size()); ``` ### Upstream Impact ```java -Lineage.ImpactAnalysis impact = Lineage.impact() - .of("dashboard", dashboardId) - .upstream() - .depth(5) - .analyze(); +import org.openmetadata.sdk.api.Lineage; + +Lineage.LineageGraph graph = Lineage.of("dashboard", dashboardId) + .upstream(3) + .downstream(0) + .fetch(); ``` ## OpenLineage Events @@ -197,6 +231,8 @@ The SDK also supports posting [OpenLineage](https://openlineage.io/) standard ev via the `OpenLineage` fluent API: ```java +import org.openmetadata.sdk.api.Lineage; + import org.openmetadata.sdk.fluent.OpenLineage; OpenLineage.setDefaultClient(client); @@ -206,7 +242,7 @@ String response = OpenLineage.event() .withEventType("COMPLETE") .withEventTime("2024-01-15T12:00:00Z") .withJob("my-etl-job", "my-namespace") - .withRun("run-id-123") + .withRun("3f2b9c1e-5d4a-4e7b-8a6c-1d2e3f4a5b6c") .addInput("source_table", "my-namespace") .addOutput("target_table", "my-namespace") .send(); @@ -215,18 +251,20 @@ String response = OpenLineage.event() ### Batch Events ```java +import org.openmetadata.sdk.fluent.OpenLineage; + // Build individual events OpenLineage.RunEventBuilder event1 = OpenLineage.event() .withEventType("START") .withEventTime("2024-01-15T12:00:00Z") .withJob("job-1", "ns") - .withRun("run-1"); + .withRun("7a1c2d3e-4b5f-4a6b-9c8d-0e1f2a3b4c5d"); OpenLineage.RunEventBuilder event2 = OpenLineage.event() .withEventType("COMPLETE") .withEventTime("2024-01-15T12:05:00Z") .withJob("job-1", "ns") - .withRun("run-1"); + .withRun("7a1c2d3e-4b5f-4a6b-9c8d-0e1f2a3b4c5d"); // Send as a batch String response = OpenLineage.batch() @@ -238,25 +276,32 @@ String response = OpenLineage.batch() ## Static API For simpler use cases, the `LineageAPI` class in `org.openmetadata.sdk.api` provides static methods -that wrap the underlying HTTP calls: +that wrap the underlying HTTP calls. They use a shared client, which you set up once with `OpenMetadata.initialize`: ```java +import java.util.Map; import org.openmetadata.sdk.api.LineageAPI; +import org.openmetadata.sdk.client.OpenMetadata; + +OpenMetadata.initialize("http://localhost:8585/api", ""); // Get lineage by entity FQN -String lineage = LineageAPI.getLineage("service.db.schema.table"); +String lineage = LineageAPI.getLineage("table/name/service.db.schema.table"); // Get lineage with depth -String lineage = LineageAPI.getLineage("service.db.schema.table", "3", "2"); +String lineageWithDepth = LineageAPI.getLineage("table/name/service.db.schema.table", "3", "2"); // Get lineage by entity type and ID -String lineage = LineageAPI.getEntityLineage("table", tableId); +String lineageById = LineageAPI.getEntityLineage("table", tableId); // Add lineage (pass a Map matching the AddLineage JSON schema) +Map lineageRequestMap = Map.of("edge", Map.of( + "fromEntity", Map.of("id", sourceTableId, "type", "table"), + "toEntity", Map.of("id", targetTableId, "type", "table"))); String result = LineageAPI.addLineage(lineageRequestMap); // Delete lineage -String result = LineageAPI.deleteLineage("table:fromId", "dashboard:toId"); +String deleted = LineageAPI.deleteLineage("table:" + sourceTableId, "dashboard:" + dashboardId); // Export lineage String csv = LineageAPI.exportLineage("service.db.schema.table", "table", "3", "2"); @@ -267,9 +312,13 @@ String csv = LineageAPI.exportLineage("service.db.schema.table", "table", "3", " All static methods have `CompletableFuture`-based async variants: ```java -CompletableFuture future = LineageAPI.getLineageAsync("service.db.schema.table"); +import java.util.concurrent.CompletableFuture; +import org.openmetadata.sdk.api.LineageAPI; + +CompletableFuture future = LineageAPI.getLineageAsync("table/name/service.db.schema.table"); future.thenAccept(lineage -> System.out.println("Lineage: " + lineage)); -CompletableFuture addFuture = LineageAPI.addLineageAsync(request); -CompletableFuture deleteFuture = LineageAPI.deleteLineageAsync("table:id1", "dashboard:id2"); +CompletableFuture addFuture = LineageAPI.addLineageAsync(lineageRequestMap); +CompletableFuture deleteFuture = LineageAPI.deleteLineageAsync( + "table:" + sourceTableId, "dashboard:" + dashboardId); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/overview.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/overview.mdx index 6320de9ce..127992019 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/overview.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/overview.mdx @@ -2,6 +2,8 @@ title: OpenMetadata SDKs description: 'Official client libraries for Python, Java, and Go to integrate with OpenMetadata APIs. Type-safe, full-featured SDKs for metadata management and automation.' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # OpenMetadata SDKs @@ -25,7 +27,7 @@ Official client libraries provide type-safe, full-featured access to OpenMetadat - Full-featured Python client + Original Client and SDK 2.0 (`metadata.sdk`) Enterprise Java integration @@ -44,15 +46,24 @@ Perfect for: - ML pipeline automation - Data quality automation +SDK 2.0 (`metadata.sdk`, OpenMetadata 1.10.0 and later): + + + +Original client: + ```python from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( OpenMetadataConnection, ) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) from metadata.ingestion.ometa.ometa_api import OpenMetadata server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -69,13 +80,15 @@ Perfect for: - Legacy system integration ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; + +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .build(); -OpenMetadataClient client = new OpenMetadataClient( - "http://localhost:8585/api", - "your-jwt-token" -); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ### Go SDK @@ -86,11 +99,11 @@ Perfect for: - High-performance services ```go -import "github.com/open-metadata/openmetadata-go-client" +import "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" -client := openmetadata.NewClient( - "http://localhost:8585/api", - "your-jwt-token", +client := ometa.NewClient( + "http://localhost:8585", + ometa.WithToken("your-jwt-token"), ) ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/python.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/python.mdx index bafcc3978..8d58ab8ab 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/python.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/python.mdx @@ -3,6 +3,8 @@ title: Python SDK | OpenMetadata Python SDK Documentation description: Master OpenMetadata'sPython SDK with comprehensive documentation, code examples, and API guides. Build powerful data discovery and governance solutions. sidebarTitle: Overview --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -17,7 +19,7 @@ We are now going to present a high-level Python API as a type-safe and gentle wr - Make sure to use the same `openmetadata-ingestion` version as your server version. For example, if you have the OpenMetadata server at version 2.0.5, you need to install: -```python +```bash pip install "openmetadata-ingestion~=2.0.5.0" ``` @@ -30,7 +32,15 @@ In the [OpenMetadata Design](/v2.1.x-SNAPSHOT/developers/architecture), we have This means that whenever we need to interact with the metadata system or develop a new connector or logic, we have to make sure that we pass the proper inputs and handle the types of outputs. -## Introducing the Python API + + +## SDK 2.0 Quick Start + +Connect with `configure()`, then create, update, and delete a table: + + + +## Introducing the Python API (Original Client) Let's suppose that we have our local OpenMetadata server running at `http:localhost:8585`. We can play with it with simple `cURL` or `httpie` commands, and if we just want to take a look at the Entity instances we have lying around, that might probably be enough. However, let's imagine that we want to create or update an ML Model Entity with a `PUT`. To do so, we need to make sure that we are providing a proper JSON, covering all the attributes and types required by the Entity definition. @@ -320,8 +330,8 @@ class CreateDatabaseRequest(BaseModel): None, description='Description of the database instance. What it has and how to use it.', ) - owner: Optional[entityReference.EntityReference] = Field( - None, description='Owner of this database' + owners: Optional[entityReferenceList.EntityReferenceList] = Field( + None, description='Owners of this database' ) service: basic.FullyQualifiedEntityName = Field( ..., @@ -335,7 +345,7 @@ class CreateDatabaseRequest(BaseModel): Note how the only non-optional fields are `name` and `service`. The type of `service`, however, is `FullyQualifiedEntityName`. This is expected, as there we need to pass the information of an existing Entity. In our case, the `fullyQualifiedName` of the `DatabaseService` we just created. -In the case of the `owner` field, repeating the exercise and reviewing the required fields to instantiate an `EntityReference` we notice how we need to pass an `id: uuid.UUID` and `type: str`. There we need to specify the `id` and `type` of an `User`. +The `owners` field takes a list of `EntityReference`. To instantiate an `EntityReference`, pass an `id: uuid.UUID` and `type: str`. Specify the `id` and `type` of a `User`. **Querying by name** @@ -404,8 +414,8 @@ Let's now update the `Table` by adding an owner. This will require us to create First, make sure that no owner has been set during the creation: ```python -print(table_entity.owner) -# None +print(table_entity.owners) +# root=[] ``` Now, create a `User`: @@ -418,19 +428,19 @@ user = metadata.create_or_update( ) ``` -Update our instance of `create_table` to add the `owner` field (we need to use the `Create` class as we'll run a `PUT`), and update the Entity: +Update your `create_table` instance to add the `owners` field. Use the `Create` class, because this runs a `PUT`. Then update the Entity: ```python from metadata.generated.schema.type.entityReference import EntityReference -create_table.owner = EntityReference(id=user.id, type="user") +create_table.owners = [EntityReference(id=user.id, type="user")] updated_table_entity = metadata.create_or_update(create_table) -print(updated_table_entity.owner) -# EntityReference(id=Uuid(__root__=UUID('48793f0c-5308-45c1-9bf4-06a82c8d7bf9')), type='user', name='random-user', description=None, displayName=None, href=Href(__root__=AnyUrl('http://localhost:8585/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9', scheme='http', host='localhost', host_type='int_domain', port='8585', path='/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9'))) +print(updated_table_entity.owners.root[0].name) +# random-user ``` -If we did not save the `updated_table_entity` variable, we should need to query it to review the `owner` field. We can run the `get_by_name` using the proper FQN definition for `Table`s: +If you didn't save the `updated_table_entity` variable, query it to review the `owners` field. Run `get_by_name` with the FQN of the table: ```python my_table = metadata.get_by_name(entity=Table, fqn="test-service-table.test-db.test-schema.test") diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/python/entities/ml-model.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/python/entities/ml-model.mdx index 37c739bce..31a999580 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/python/entities/ml-model.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/python/entities/ml-model.mdx @@ -35,7 +35,7 @@ There are some common questions with lifecycle tools, such as _Where (URL) is th This information, together with the rest of the features brought by OpenMetadata, lets us also manage topics such as schema changes in the sources or feature drifts, with the corresponding alerting systems. -While we can already extract certain pieces of information automatically via our Connectors (e.g., [Mlflow](/v2.1.x-SNAPSHOT/connectors/ml-model/mlflow)), there are attributes that we'll need to fill in by ourselves. Thanks to the [Solution Design](/v2.1.x-SNAPSHOT/main-concepts/high-level-design) of OpenMetadata and the [Python SDK](/v2.1.x-SNAPSHOT/api-reference/sdk/python), this is going to be a rather easy task that will unlock the full power of your **organization's metadata**. +While we can already extract certain pieces of information automatically via our Connectors, for example [Mlflow](/v2.1.x-SNAPSHOT/connectors/ml-model/mlflow), there are attributes that we'll need to fill in by ourselves. Thanks to the [Solution Design](/v2.1.x-SNAPSHOT/main-concepts/high-level-design) of OpenMetadata and the [Python SDK](/v2.1.x-SNAPSHOT/api-reference/sdk/python), this is going to be a rather easy task that will unlock the full power of your **organization's metadata**. ## Properties Now that we have a clearer view of what we are trying to achieve, let's jump into a deeper view on the `MlModel` Entity [definition](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/entity/data/mlmodel.json): @@ -43,7 +43,7 @@ Now that we have a clearer view of what we are trying to achieve, let's jump int - The `name` and `algorithm` are the only required properties when [creating](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/api/data/createMlModel.json) an `MlModel`. We can just bring the top shell to the catalogue automatically and then choose which models we want to enrich. - The `dashboard` is a reference to a Dashboard Entity present in OpenMetadata (what we call an `EntityReference`). This should be a dashboard we have built that shows the evolution of our performance metrics. The **transparency** on ML services is integral, and that is why we have added it to the `MlModel` properties. - A server with the URL on where to reach the model **endpoint**, to `POST` input data or retrieve a prediction. -- The mlStore specifies the **location** containing the model. Here we support both passing a URI with the object (e.g. `pkl`) location and/or a Docker image in its repository. +- The mlStore specifies the **location** containing the model. Here we support both passing a URI with the object, for example `pkl` location and/or a Docker image in its repository. - With `mlHyperParameters` we can add the `name`, `value` and `description` of the used hyperparameters. On top of this information, we can also have common metadata attributes, such as the Owner, tags, followers or **versioning**. @@ -80,7 +80,7 @@ MlFeature( Some properties that we can define when instantiating an `MlFeature` are the name, the `dataType` and the `featureAlgorithm`. Now, the question is: Are we being thorough in describing what is really going on? Are we going to be able to detect at any point in the future if this model is based on biased predictors (such as gender)? -Here we want to give more **depth**. In order to do so, we can inform another property of the `MlFeature`, which are the `MlFeatureSource`s. The idea is that any feature can be based on an arbitrary number of real/physical sources (e.g., the columns of a Table), and informing this field will allow us to obtain this **relationship**. +Here we want to give more **depth**. In order to do so, we can inform another property of the `MlFeature`, which are the `MlFeatureSource`s. The idea is that any feature can be based on an arbitrary number of real/physical sources, for example the columns of a Table, and informing this field will allow us to obtain this **relationship**. If we add this extra information, our feature will look like this: @@ -117,9 +117,18 @@ Thanks to this extra piece of information, we now can run the following method o ```python from metadata.ingestion.ometa.ometa_api import OpenMetadata -from metadata.ingestion.ometa.openmetadata_rest import MetadataServerConfig +from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( + OpenMetadataConnection, +) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) -server_config = MetadataServerConfig(api_endpoint="http://localhost:8585/api") +server_config = OpenMetadataConnection( + hostPort="http://localhost:8585/api", + authProvider="openmetadata", + securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"), +) metadata = OpenMetadata(server_config) metadata.add_mlmodel_lineage(model=my_mlmodel_entity) diff --git a/v2.1.x-SNAPSHOT/api-reference/sdk/python/overview.mdx b/v2.1.x-SNAPSHOT/api-reference/sdk/python/overview.mdx index c193ace70..828043502 100644 --- a/v2.1.x-SNAPSHOT/api-reference/sdk/python/overview.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/sdk/python/overview.mdx @@ -1,7 +1,10 @@ --- title: Python SDK Overview +sidebarTitle: Original Client and SDK 2.0 description: 'Full-featured Python client library for OpenMetadata integration' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -15,7 +18,17 @@ Install the OpenMetadata Python SDK using pip: pip install openmetadata-ingestion ``` -## Quick Start + + +## Quick Start: SDK 2.0 + +Connect with `configure()`, then create, update, and delete a table: + + + +## Quick Start: Original Client + +Connect with `OpenMetadataConnection`, then read and update entities: ### Basic Connection @@ -31,7 +44,7 @@ from metadata.generated.schema.security.client.openMetadataJWTClientConfig impor # Configure connection server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -62,7 +75,7 @@ table = metadata.get_by_name( ) if table: - print(f"Table: {table.name}") + print(f"Table: {table.name.root}") print(f"Columns: {len(table.columns) if table.columns else 0}") ``` @@ -106,7 +119,7 @@ table = metadata.get_by_name( # List entities with pagination tables = metadata.list_entities( entity=Table, - fields=["owner", "tags"], + fields=["owners", "tags"], limit=50 ) ``` @@ -117,12 +130,12 @@ tables = metadata.list_entities( # Generator for large datasets all_tables = metadata.list_all_entities( entity=Table, - fields=["owner", "columns"], - params={"service": "your-service-name"} + fields=["owners", "columns"], + params={"databaseSchema": "your-service.your-database.your-schema"} ) for table in all_tables: - print(f"Processing table: {table.name}") + print(f"Processing table: {table.name.root}") ``` ### Entity References @@ -136,26 +149,26 @@ table_ref = metadata.get_entity_reference( # Use in other entity creation if table_ref: - print(f"Table reference: {table_ref.id}") + print(f"Table reference: {table_ref.id.root}") ``` ## Advanced Features -### Custom Configuration +### Validating a Custom Certificate Authority (CA) Certificate + +To trust a private CA, pass the path to its certificate in `sslConfig`: ```python -# Using custom authentication -from metadata.generated.schema.security.client.basicAuthenticationProvider import ( - BasicAuthenticationProvider, -) +from metadata.generated.schema.security.ssl.validateSSLClientConfig import ValidateSslClientConfig server_config = OpenMetadataConnection( hostPort="https://your-openmetadata-instance.com/api", - authProvider="basic", - securityConfig=BasicAuthenticationProvider( - username="your-username", - password="your-password" + authProvider="openmetadata", + securityConfig=OpenMetadataJWTClientConfig( + jwtToken="your-jwt-token" ), + verifySSL="validate", + sslConfig=ValidateSslClientConfig(caCertificate="/path/to/rootCert"), ) metadata = OpenMetadata(server_config) @@ -164,18 +177,10 @@ metadata = OpenMetadata(server_config) ### Error Handling ```python -from metadata.ingestion.ometa.ometa_api import ( - OpenMetadata, - InvalidEntityException, - EmptyPayloadException -) - -try: - table = metadata.get_by_name(entity=Table, fqn="non-existent-table") -except InvalidEntityException as e: - print(f"Invalid entity: {e}") -except EmptyPayloadException as e: - print(f"No data received: {e}") +# get_by_name returns None when the entity does not exist +table = metadata.get_by_name(entity=Table, fqn="non-existent-table") +if table is None: + print("Table not found") ``` ### Working with Versions @@ -200,11 +205,11 @@ all_tables = metadata.list_all_entities(entity=Table) matching_tables = [ table for table in all_tables - if "customer" in table.name.lower() + if "customer" in table.name.root.lower() ] for table in matching_tables: - print(f"Found customer table: {table.fullyQualifiedName}") + print(f"Found customer table: {table.fullyQualifiedName.root}") ``` ### Metadata Automation @@ -213,30 +218,28 @@ for table in matching_tables: # Bulk update table descriptions tables_to_update = metadata.list_all_entities( entity=Table, - params={"service": "production-db"} + params={"databaseSchema": "production-service.production-db.public"} ) for table in tables_to_update: if not table.description: # Update with a default description - table.description = f"Production table: {table.name}" + table.description = f"Production table: {table.name.root}" metadata.create_or_update(data=table) ``` ### Lineage Management ```python -from metadata.generated.schema.type.entityLineage import EntityLineage - -# Get table lineage +# Get table lineage (returns a dict) lineage = metadata.get_lineage_by_name( entity=Table, fqn="service.database.schema.table" ) if lineage: - print(f"Upstream entities: {len(lineage.upstreamEdges)}") - print(f"Downstream entities: {len(lineage.downstreamEdges)}") + print(f"Upstream edges: {len(lineage['upstreamEdges'])}") + print(f"Downstream edges: {len(lineage['downstreamEdges'])}") ``` ## API Reference diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/create.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/create.mdx index 28f495da5..70ba29f4a 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/create.mdx @@ -58,7 +58,7 @@ Create a new team for organizing users and controlling access to data assets. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -81,8 +81,8 @@ Create a new team for organizing users and controlling access to data assets. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -105,20 +105,23 @@ request = CreateTeamRequest( ) team = Teams.create(request) -print(f"Created: {team.fullyQualifiedName}") +print(f"Created: {team.fullyQualifiedName.root}") ``` ```java POST /v1/teams -import static org.openmetadata.sdk.fluent.Teams.*; - -// Create using builder pattern -var team = Teams.builder() - .name("Accounting") - .teamType("Group") - .displayName("Accounting") - .description("Accounting team under Finance") - .parents(List.of("4f87a3ea-d798-4509-8c64-5b11f8a96f89")) - .create(); +import java.util.List; +import java.util.UUID; +import org.openmetadata.schema.api.teams.CreateTeam; + +// client is an initialized OpenMetadataClient. +var request = new CreateTeam() + .withName("Accounting") + .withTeamType(CreateTeam.TeamType.GROUP) + .withDisplayName("Accounting") + .withDescription("Accounting team under Finance") + .withParents(List.of(UUID.fromString("4f87a3ea-d798-4509-8c64-5b11f8a96f89"))); + +var team = client.teams().create(request); ``` ```bash POST /v1/teams diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/delete.mdx index f3ec3fd9b..d34991d17 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/delete.mdx @@ -51,11 +51,11 @@ Teams.delete( ) # Delete by name -Teams.delete_by_name("Accounting") +Teams.delete(Teams.retrieve_by_name("Accounting").id) # Delete by name with options -Teams.delete_by_name( - "Accounting", +Teams.delete( + Teams.retrieve_by_name("Accounting").id, hard_delete=True ) @@ -64,22 +64,23 @@ Teams.restore("449b5f25-4cbb-42db-8f71-3be2c5cd888a") ``` ```java DELETE /v1/teams/{id} -import static org.openmetadata.sdk.fluent.Teams.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "449b5f25-4cbb-42db-8f71-3be2c5cd888a"; // Soft delete -Teams.delete("449b5f25-4cbb-42db-8f71-3be2c5cd888a").execute(); +client.teams().delete(id); -// Hard delete -Teams.delete("449b5f25-4cbb-42db-8f71-3be2c5cd888a") - .hardDelete() - .execute(); +// Restore +client.teams().restore(id); -// Delete by name -Teams.deleteByName("Accounting") - .execute(); +// Hard delete +client.teams().delete(id, Map.of("hardDelete", "true")); -// Restore -Teams.restore("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); +// Delete by name: look up the ID first +var team = client.teams().getByName("Accounting"); +client.teams().delete(team.getId().toString()); ``` ```bash DELETE /v1/teams/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/list.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/list.mdx index 8839a337a..529d3fee8 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/list.mdx @@ -47,49 +47,47 @@ configure( # List first page teams = Teams.list(limit=50) -for team in teams.data: - print(f"{team.fullyQualifiedName} ({team.teamType})") +for team in teams.entities: + print(f"{team.fullyQualifiedName.root} ({team.teamType.value})") # List all with auto-pagination for team in Teams.list_all(): - print(f"{team.fullyQualifiedName}") + print(f"{team.fullyQualifiedName.root}") # Filter by parent team teams = Teams.list( - parentTeam="Finance", + filters={"parentTeam": "Finance"}, fields=["users", "parents", "policies"], limit=50 ) -for team in teams.data: - print(f"{team.fullyQualifiedName}") +for team in teams.entities: + print(f"{team.fullyQualifiedName.root}") if team.users: - print(f" Users: {[u.name for u in team.users]}") + print(f" Users: {[u.name for u in team.users.root]}") if team.parents: - print(f" Parents: {[p.name for p in team.parents]}") + print(f" Parents: {[p.name for p in team.parents.root]}") ``` ```java GET /v1/teams -import static org.openmetadata.sdk.fluent.Teams.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Teams.list() - .limit(50) - .execute(); - -for (var team : result.getData()) { - System.out.println(team.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.teams().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by parent team with fields -var result = Teams.list() - .parentTeam("Finance") - .fields("users", "parents", "policies") - .limit(50) - .execute(); - -for (var team : result.getData()) { - System.out.println(team.getFullyQualifiedName()); +var filtered = new ListParams() + .addFilter("parentTeam", "Finance") + .setFields("users,parents,policies") + .setLimit(50); +var filteredPage = client.teams().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/retrieve.mdx index dcb6c1464..afa2a06c2 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/retrieve.mdx @@ -16,7 +16,7 @@ Get a single team by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `users,parents,children,policies,domains,owners`). + Comma-separated list of fields to include, for example `users,parents,children,policies,domains,owners`. @@ -28,7 +28,7 @@ Get a single team by its unique ID or fully qualified name. Use `GET /v1/teams/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the team (e.g., `Accounting`). + Fully qualified name of the team, for example `Accounting`. @@ -51,7 +51,7 @@ configure( # Get by ID team = Teams.retrieve("449b5f25-4cbb-42db-8f71-3be2c5cd888a") -print(f"{team.fullyQualifiedName}: {team.teamType}") +print(f"{team.fullyQualifiedName.root}: {team.teamType.value}") # Get by ID with fields team = Teams.retrieve( @@ -70,25 +70,21 @@ team = Teams.retrieve_by_name( ``` ```java GET /v1/teams/{id} -import static org.openmetadata.sdk.fluent.Teams.*; - -// Get by ID -var team = Teams.retrieve("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); +// client is an initialized OpenMetadataClient. +var team = client.teams().get("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); // Get by ID with fields -var team = Teams.retrieve( +var teamWithFields = client.teams().get( "449b5f25-4cbb-42db-8f71-3be2c5cd888a", - "users,parents,policies" -); + "users,parents,policies"); // Get by fully qualified name -var team = Teams.retrieveByName("Accounting"); +var teamByName = client.teams().getByName("Accounting"); // Get by name with fields -var team = Teams.retrieveByName( +var teamByNameWithFields = client.teams().getByName( "Accounting", - "users,parents,children" -); + "users,parents,children"); ``` ```bash GET /v1/teams/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/update.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/update.mdx index 23bb6b1c3..20b1f332c 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/update.mdx @@ -44,7 +44,7 @@ Send a JSON object with the fields to update. Only provided fields are changed. - Type of owner entity (e.g., `user`, `team`). + Type of owner entity, for example `user`, `team`. @@ -63,8 +63,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -83,16 +83,16 @@ team.description = "Updated: Accounting team handling all financial reporting" team.displayName = "Accounting & Reporting" updated = Teams.update(team) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/teams/{id} -import static org.openmetadata.sdk.fluent.Teams.*; - -// Retrieve, modify, and update -var team = Teams.retrieve("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); +// client is an initialized OpenMetadataClient. +var teamId = "449b5f25-4cbb-42db-8f71-3be2c5cd888a"; +var team = client.teams().get(teamId); team.setDescription("Updated: Accounting team handling all financial reporting"); -var updated = Teams.update(team); + +var updated = client.teams().update(teamId, team); ``` ```bash PATCH /v1/teams/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/versions.mdx index 311e58057..b82b6a399 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/teams/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/teams/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/teams/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Teams @@ -40,31 +42,29 @@ configure( # List all versions versions = Teams.get_versions("449b5f25-4cbb-42db-8f71-3be2c5cd888a") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version team_v1 = Teams.get_specific_version( "449b5f25-4cbb-42db-8f71-3be2c5cd888a", "0.1" ) -print(f"Original name: {team_v1.name}") +print(f"Original name: {team_v1.name.root}") ``` ```java GET /v1/teams/{id}/versions -import static org.openmetadata.sdk.fluent.Teams.*; +// client is an initialized OpenMetadataClient. +var id = "449b5f25-4cbb-42db-8f71-3be2c5cd888a"; // List all versions -var history = Teams.getVersions("449b5f25-4cbb-42db-8f71-3be2c5cd888a"); - +var history = client.teams().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Teams.getSpecificVersion( - "449b5f25-4cbb-42db-8f71-3be2c5cd888a", - 0.1 -); +var v1 = client.teams().getVersion(id, 0.1); System.out.println("Name: " + v1.getName()); ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/create.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/create.mdx index adcf2f94c..ec4d8adcd 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/create.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/create.mdx @@ -51,8 +51,8 @@ Starting in OpenMetadata 2.0.3, assigning a user to a closed team (`isJoinable: Array of persona references to assign to the user. - - Fully qualified name of the domain to assign for governance purposes. + + Fully qualified names of the domains to assign for governance purposes. @@ -64,7 +64,7 @@ Starting in OpenMetadata 2.0.3, assigning a user to a closed team (`isJoinable: - Timezone of the user (e.g., `America/New_York`). + Timezone of the user, for example `America/New_York`. @@ -90,19 +90,20 @@ request = CreateUserRequest( ) user = Users.create(request) -print(f"Created: {user.fullyQualifiedName}") +print(f"Created: {user.fullyQualifiedName.root}") ``` ```java POST /v1/users -import static org.openmetadata.sdk.fluent.Users.*; - -// Create using builder pattern -var user = Users.builder() - .name("aaron_johnson0") - .displayName("Aaron Johnson") - .email("aaron_johnson0@gmail.com") - .description("Data analyst in the Sales team") - .create(); +import org.openmetadata.schema.api.teams.CreateUser; + +// client is an initialized OpenMetadataClient. +var request = new CreateUser() + .withName("aaron_johnson0") + .withDisplayName("Aaron Johnson") + .withEmail("aaron_johnson0@gmail.com") + .withDescription("Data analyst in the Sales team"); + +var user = client.users().create(request); ``` ```bash POST /v1/users diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/delete.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/delete.mdx index f794ffadf..802f00d03 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/delete.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/delete.mdx @@ -28,7 +28,7 @@ Delete a user by ID or fully qualified name. Supports soft delete (default), har Use `DELETE /v1/users/name/{fqn}` to delete by fully qualified name. - Fully qualified name of the user (e.g., `aaron_johnson0`). + Fully qualified name of the user, for example `aaron_johnson0`. @@ -67,11 +67,11 @@ Users.delete( ) # Delete by name -Users.delete_by_name("aaron_johnson0") +Users.delete(Users.retrieve_by_name("aaron_johnson0").id) # Delete by name with options -Users.delete_by_name( - "aaron_johnson0", +Users.delete( + Users.retrieve_by_name("aaron_johnson0").id, hard_delete=True ) @@ -80,22 +80,23 @@ Users.restore("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") ``` ```java DELETE /v1/users/{id} -import static org.openmetadata.sdk.fluent.Users.*; +import java.util.Map; + +// client is an initialized OpenMetadataClient. +var id = "77655e6e-ad33-49da-bbca-db4ba4d4e2cd"; // Soft delete -Users.delete("77655e6e-ad33-49da-bbca-db4ba4d4e2cd").execute(); +client.users().delete(id); -// Hard delete -Users.delete("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") - .hardDelete() - .execute(); +// Restore +client.users().restore(id); -// Delete by name -Users.deleteByName("aaron_johnson0") - .execute(); +// Hard delete +client.users().delete(id, Map.of("hardDelete", "true")); -// Restore -Users.restore("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); +// Delete by name: look up the ID first +var user = client.users().getByName("aaron_johnson0"); +client.users().delete(user.getId().toString()); ``` ```bash DELETE /v1/users/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/list.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/list.mdx index d222cab92..6a8a7d730 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/list.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/list.mdx @@ -55,52 +55,50 @@ configure( # List first page users = Users.list(limit=50) -for user in users.data: - print(f"{user.fullyQualifiedName}") +for user in users.entities: + print(f"{user.fullyQualifiedName.root}") # List all with auto-pagination for user in Users.list_all(): - print(f"{user.fullyQualifiedName}") + print(f"{user.fullyQualifiedName.root}") # Filter by team with fields users = Users.list( - team="Sales", + filters={"team": "Sales"}, fields=["teams", "roles", "domains"], limit=50 ) -for user in users.data: - print(f"{user.fullyQualifiedName}") +for user in users.entities: + print(f"{user.fullyQualifiedName.root}") if user.teams: - print(f" Teams: {[t.name for t in user.teams]}") + print(f" Teams: {[t.name for t in user.teams.root]}") if user.roles: - print(f" Roles: {[r.name for r in user.roles]}") + print(f" Roles: {[r.name for r in user.roles.root]}") # Filter bot accounts -bots = Users.list(isBot=True, limit=50) +bots = Users.list(filters={"isBot": "true"}, limit=50) ``` ```java GET /v1/users -import static org.openmetadata.sdk.fluent.Users.*; +import org.openmetadata.sdk.models.ListParams; +// client is an initialized OpenMetadataClient. // List first page -var result = Users.list() - .limit(50) - .execute(); - -for (var user : result.getData()) { - System.out.println(user.getFullyQualifiedName()); +var params = new ListParams().setLimit(50); +var page = client.users().list(params); +for (var item : page.getData()) { + System.out.println(item.getFullyQualifiedName()); } // Filter by team with fields -var result = Users.list() - .team("Sales") - .fields("teams", "roles", "domains") - .limit(50) - .execute(); - -for (var user : result.getData()) { - System.out.println(user.getFullyQualifiedName()); +var filtered = new ListParams() + .addFilter("team", "Sales") + .setFields("teams,roles,domains") + .setLimit(50); +var filteredPage = client.users().list(filtered); +for (var item : filteredPage.getData()) { + System.out.println(item.getFullyQualifiedName()); } ``` diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/retrieve.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/retrieve.mdx index 3cac49182..5e8ec215e 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/retrieve.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/retrieve.mdx @@ -16,7 +16,7 @@ Get a single user by its unique ID or fully qualified name. - Comma-separated list of fields to include (e.g., `teams,roles,personas,domains,follows,owns`). + Comma-separated list of fields to include, for example `teams,roles,personas,domains,follows,owns`. @@ -28,7 +28,7 @@ Get a single user by its unique ID or fully qualified name. Use `GET /v1/users/name/{fqn}` to retrieve by fully qualified name. - Fully qualified name of the user (e.g., `aaron_johnson0`). + Fully qualified name of the user, for example `aaron_johnson0`. @@ -51,7 +51,7 @@ configure( # Get by ID user = Users.retrieve("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") -print(f"{user.fullyQualifiedName}: {user.email}") +print(f"{user.fullyQualifiedName.root}: {user.email.root}") # Get by ID with fields user = Users.retrieve( @@ -70,25 +70,21 @@ user = Users.retrieve_by_name( ``` ```java GET /v1/users/{id} -import static org.openmetadata.sdk.fluent.Users.*; - -// Get by ID -var user = Users.retrieve("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); +// client is an initialized OpenMetadataClient. +var user = client.users().get("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); // Get by ID with fields -var user = Users.retrieve( +var userWithFields = client.users().get( "77655e6e-ad33-49da-bbca-db4ba4d4e2cd", - "teams,roles,domains" -); + "teams,roles,domains"); // Get by fully qualified name -var user = Users.retrieveByName("aaron_johnson0"); +var userByName = client.users().getByName("aaron_johnson0"); // Get by name with fields -var user = Users.retrieveByName( +var userByNameWithFields = client.users().getByName( "aaron_johnson0", - "teams,roles,domains" -); + "teams,roles,domains"); ``` ```bash GET /v1/users/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/update.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/update.mdx index ff7fbba4b..9cfd2eb85 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/update.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/update.mdx @@ -26,7 +26,7 @@ Adding a user to a closed team (`isJoinable: false`) requires an administrator. Use `PATCH /v1/users/name/{fqn}` to update by fully qualified name. - Fully qualified name of the user (e.g., `aaron_johnson0`). + Fully qualified name of the user, for example `aaron_johnson0`. ## Body Parameters @@ -77,8 +77,8 @@ Send a JSON object with the fields to update. Only provided fields are changed. - - Updated domain FQN. + + Updated domains, as fully qualified names. @@ -101,16 +101,16 @@ user.description = "Senior data analyst in the Sales team" user.displayName = "Aaron M. Johnson" updated = Users.update(user) -print(f"Updated to version {updated.version}") +print(f"Updated to version {updated.version.root}") ``` ```java PATCH /v1/users/{id} -import static org.openmetadata.sdk.fluent.Users.*; - -// Retrieve, modify, and update -var user = Users.retrieve("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); +// client is an initialized OpenMetadataClient. +var userId = "77655e6e-ad33-49da-bbca-db4ba4d4e2cd"; +var user = client.users().get(userId); user.setDescription("Senior data analyst in the Sales team"); -var updated = Users.update(user); + +var updated = client.users().update(userId, user); ``` ```bash PATCH /v1/users/{id} diff --git a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/versions.mdx b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/versions.mdx index 7200919f2..0e1ebf62d 100644 --- a/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/versions.mdx +++ b/v2.1.x-SNAPSHOT/api-reference/teams-and-users/users/versions.mdx @@ -24,11 +24,13 @@ Use `GET /v1/users/{id}/versions/{version}` to retrieve a specific version. - Version number to retrieve (e.g., `0.2`). + Version number to retrieve, for example `0.2`. ```python GET /v1/users/{id}/versions +import json + from metadata.sdk import configure from metadata.sdk.entities import Users @@ -40,7 +42,8 @@ configure( # List all versions versions = Users.get_versions("77655e6e-ad33-49da-bbca-db4ba4d4e2cd") for v in versions: - print(f"Version {v.version}: {v.description}") + version = json.loads(v) + print(f"Version {version['version']}: {version.get('description')}") # Get a specific version user_v1 = Users.get_specific_version( @@ -51,20 +54,17 @@ print(f"Original display name: {user_v1.displayName}") ``` ```java GET /v1/users/{id}/versions -import static org.openmetadata.sdk.fluent.Users.*; +// client is an initialized OpenMetadataClient. +var id = "77655e6e-ad33-49da-bbca-db4ba4d4e2cd"; // List all versions -var history = Users.getVersions("77655e6e-ad33-49da-bbca-db4ba4d4e2cd"); - +var history = client.users().getVersionList(id); for (var version : history.getVersions()) { System.out.println("Version: " + version); } // Get a specific version -var v1 = Users.getSpecificVersion( - "77655e6e-ad33-49da-bbca-db4ba4d4e2cd", - 0.1 -); +var v1 = client.users().getVersion(id, 0.1); System.out.println("Display Name: " + v1.getDisplayName()); ``` diff --git a/v2.1.x-SNAPSHOT/connectors/ingestion/deployment.mdx b/v2.1.x-SNAPSHOT/connectors/ingestion/deployment.mdx index 172f51ddb..2f5db10a3 100644 --- a/v2.1.x-SNAPSHOT/connectors/ingestion/deployment.mdx +++ b/v2.1.x-SNAPSHOT/connectors/ingestion/deployment.mdx @@ -277,14 +277,15 @@ it will be the [AirflowRESTClient](https://github.com/open-metadata/OpenMetadata First, let's see what it is needed to instantiate the Airflow REST Client: ```java -public AirflowRESTClient(AirflowConfiguration airflowConfig) { - super( - airflowConfig.getUsername(), - airflowConfig.getPassword(), - airflowConfig.getApiEndpoint(), - airflowConfig.getHostIp(), - airflowConfig.getTimeout()); - } +public AirflowRESTClient(PipelineServiceClientConfiguration config) throws KeyStoreException { + super(config); + ... + this.username = getStringParam(params, USERNAME_KEY); + this.password = getStringParam(params, PASSWORD_KEY); + ... + this.serviceURL = validateServiceURL(config.getApiEndpoint()); + ... +} ``` If we focus on the important properties here, we can see: diff --git a/v2.1.x-SNAPSHOT/deployment/secrets-manager/how-to-add-a-new-implementation.mdx b/v2.1.x-SNAPSHOT/deployment/secrets-manager/how-to-add-a-new-implementation.mdx index 6f52295b8..1ae5ab4c0 100644 --- a/v2.1.x-SNAPSHOT/deployment/secrets-manager/how-to-add-a-new-implementation.mdx +++ b/v2.1.x-SNAPSHOT/deployment/secrets-manager/how-to-add-a-new-implementation.mdx @@ -32,22 +32,43 @@ You can find [this](https://github.com/open-metadata/OpenMetadata/blob/main/open Once we have updated the JSON Schema, we can start implementing our Secrets Manager, extending the `ExternalSecretsManager.java` abstract class located [here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-service/src/main/java/org/openmetadata/service/secrets/ExternalSecretsManager.java). For example: ```java -public abstract class AwesomeSecretsManager extends ExternalSecretsManager { +public class AwesomeSecretsManager extends ExternalSecretsManager { - protected AwesomeSecretsManager(String clusterPrefix) { - super(SecretsManagerProvider.AWESOME_SM, clusterPrefix); + private static AwesomeSecretsManager instance = null; + + private AwesomeSecretsManager(SecretsConfig secretsConfig) { + super(SecretsManagerProvider.AWESOME_SM, secretsConfig); } + @Override void storeSecret(String secretName, String secretValue) { // your implementation } + + @Override void updateSecret(String secretName, String secretValue) { // your implementation } + @Override String getSecret(String secretName) { // your implementation } + + @Override + protected void deleteSecretInternal(String secretName) { + // your implementation + } + + @Override + protected boolean isNotFoundException(Exception exception) { + // your implementation + } + + public static AwesomeSecretsManager getInstance(SecretsConfig secretsConfig) { + if (instance == null) instance = new AwesomeSecretsManager(secretsConfig); + return instance; + } } ``` @@ -55,8 +76,7 @@ After this, we can update `SecretsManagerFactory.java` which is a factory class. ```java ... - case AWESOME_SM: - return AwesomeSecretsManager.getInstance(config, clusterName); + case AWESOME_SM -> secretsManager = AwesomeSecretsManager.getInstance(secretsConfig); ... ``` diff --git a/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx b/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx index b19e93a06..825df844a 100644 --- a/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx +++ b/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation-chunking.mdx @@ -12,7 +12,8 @@ For large datasets that don't fit in memory, validate data in chunks: ```python import pandas as pd -from metadata.sdk.data_quality.dataframes.dataframe_validator import DataFrameValidator, ValidationResult +from metadata.sdk.data_quality.dataframes.dataframe_validator import DataFrameValidator +from metadata.sdk.data_quality.dataframes.validation_results import ValidationResult validator = DataFrameValidator() validator.add_openmetadata_table_tests("Postgres.warehouse.staging.transactions") @@ -144,7 +145,7 @@ print(f"Validation {'succeeded' if result.success else 'failed'}") As of version 1.11.0.0 of the SDK, DataFrameValidator supports only one failure mode: short circuit. ```python -from metadata.sdk.data_quality.dataframes import FailureMode +from metadata.sdk.data_quality.dataframes.validation_results import FailureMode # SHORT_CIRCUIT (default): Stop on first test failure result = validator.validate(df, mode=FailureMode.SHORT_CIRCUIT) @@ -181,7 +182,7 @@ for test_case, test_result in result.test_cases_and_results: ### Merging Results from Multiple Chunks ```python -from metadata.sdk.data_quality.dataframes import ValidationResult +from metadata.sdk.data_quality.dataframes.validation_results import ValidationResult results = [] diff --git a/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx b/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx index 53b017fbb..f4317cd1c 100644 --- a/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx +++ b/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/dataframe-validation.mdx @@ -79,7 +79,7 @@ if result.success: else: print("✗ Validation failed") for test_case, test_result in result.test_cases_and_results: - if test_result.testCaseStatus != "Success": + if test_result.testCaseStatus.value != "Success": print(f" - {test_case.name.root}: {test_result.result}") ``` diff --git a/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx b/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx index cb57cdbe1..f645f355d 100644 --- a/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx +++ b/v2.1.x-SNAPSHOT/how-to-guides/data-quality-observability/quality/data-quality-as-code/getting-started.mdx @@ -406,7 +406,7 @@ If you experience connection timeouts, verify: If you encounter import errors: -```python +```text ModuleNotFoundError: No module named 'metadata' ``` diff --git a/v2.1.x-SNAPSHOT/sdk/ai-sdk.mdx b/v2.1.x-SNAPSHOT/sdk/ai-sdk.mdx index 0b64c2882..47c2b02c9 100644 --- a/v2.1.x-SNAPSHOT/sdk/ai-sdk.mdx +++ b/v2.1.x-SNAPSHOT/sdk/ai-sdk.mdx @@ -92,7 +92,7 @@ const client = new AISdk({ ```java Java import io.openmetadata.ai.AISdk; -AISdk client = new AISdk.Builder() +AISdk client = AISdk.builder() .host("https://your-openmetadata-instance.com") .token("your-bot-jwt-token") .build(); @@ -144,7 +144,7 @@ console.log(`Created persona: ${persona.name}`); import io.openmetadata.ai.models.CreatePersonaRequest; import io.openmetadata.ai.models.PersonaInfo; -CreatePersonaRequest request = new CreatePersonaRequest.Builder() +CreatePersonaRequest request = CreatePersonaRequest.builder() .name("DataAnalyst") .description("A meticulous data analyst focused on data quality") .prompt("You are an expert data analyst working with OpenMetadata. " @@ -153,7 +153,7 @@ CreatePersonaRequest request = new CreatePersonaRequest.Builder() .displayName("Data Analyst") .build(); -PersonaInfo persona = client.createPersona(request); +PersonaInfo persona = client.personas().create(request); System.out.println("Created persona: " + persona.getName()); ``` @@ -187,7 +187,10 @@ for (const persona of personas) { ``` ```java Java -List personas = client.listPersonas(); +import io.openmetadata.ai.models.PersonaInfo; +import java.util.List; + +List personas = client.personas().list(); for (PersonaInfo persona : personas) { System.out.println(persona.getName() + ": " + persona.getDescription()); } @@ -248,23 +251,24 @@ console.log(`Created agent: ${agent.name}`); ``` ```java Java -import io.openmetadata.ai.models.CreateAgentRequest; import io.openmetadata.ai.models.AgentInfo; +import io.openmetadata.ai.models.CreateAgentRequest; +import java.util.List; -CreateAgentRequest request = new CreateAgentRequest.Builder() +// Pass the builder to create(); don't call build() +CreateAgentRequest.Builder request = CreateAgentRequest.builder() .name("DataQualityPlannerAgent") .description("Analyzes tables and recommends data quality tests") .persona("DataAnalyst") .displayName("Data Quality Planner") .apiEnabled(true) - .abilities(List.of( + .skills(List.of( "search_metadata", "get_entity_details", "get_entity_lineage" - )) - .build(); + )); -AgentInfo agent = client.createAgent(request); +AgentInfo agent = client.agents().create(request); System.out.println("Created agent: " + agent.getName()); ``` @@ -279,7 +283,7 @@ System.out.println("Created agent: " + agent.getName()); | `persona` | string | Yes | Name of an existing persona | | `display_name` | string | No | Human-readable name (defaults to `name`) | | `api_enabled` | boolean | No | Must be `true` for SDK invocation (default: `false`) | -| `abilities` | array | No | Allowed MCP tool names (all tools if omitted) | +| `abilities` | array | No | Allowed MCP tool names (all tools if omitted). In the Java SDK, the builder method is `skills`. | | `prompt` | string | No | Additional system prompt appended to persona's base prompt | | `provider` | string | No | LLM provider: `openai`, `anthropic`, `azure_openai` (default: `openai`) | | `bot_name` | string | No | OpenMetadata bot for metadata operations | @@ -306,7 +310,10 @@ for (const agent of agents) { ``` ```java Java -List agents = client.listAgents(); +import io.openmetadata.ai.models.AgentInfo; +import java.util.List; + +List agents = client.agents().list(); for (AgentInfo agent : agents) { System.out.println(agent.getName() + ": " + agent.getDescription()); } @@ -341,8 +348,10 @@ console.log(`Tools used: ${response.toolsUsed}`); ``` ```java Java +import io.openmetadata.ai.models.InvokeResponse; + InvokeResponse response = client.agent("DataQualityPlannerAgent") - .call("What data quality tests should I add for the customers table?"); + .invoke("What data quality tests should I add for the customers table?"); System.out.println(response.getResponse()); ``` @@ -398,12 +407,12 @@ for await (const event of client.agent('DataQualityPlannerAgent').stream( ```java Java client.agent("DataQualityPlannerAgent") - .stream("Analyze the orders table") - .forEach(event -> { + .stream("Analyze the orders table", event -> { switch (event.getType()) { - case "content" -> System.out.print(event.getContent()); - case "tool_use" -> System.out.println("\n[Using: " + event.getToolName() + "]"); - case "end" -> System.out.println("\nDone!"); + case CONTENT -> System.out.print(event.getContent()); + case TOOL_USE -> System.out.println("\n[Using: " + event.getToolName() + "]"); + case END -> System.out.println("\nDone!"); + default -> { } } }); ``` diff --git a/v2.1.x-SNAPSHOT/sdk/go.mdx b/v2.1.x-SNAPSHOT/sdk/go.mdx index 0b60e1b04..4cb52c437 100644 --- a/v2.1.x-SNAPSHOT/sdk/go.mdx +++ b/v2.1.x-SNAPSHOT/sdk/go.mdx @@ -25,20 +25,32 @@ go get github.com/open-metadata/openmetadata-sdk/openmetadata-go-client ## Create a Client -To interact with the OpenMetadata API, create a `Client` by providing the server URL and a JWT token for authentication: +To interact with the OpenMetadata API, create a `Client` by providing the server URL and a JWT token for authentication. Pass the server address without the `/api` suffix (for example `http://localhost:8585`). The client adds `/api/v1` itself. ```go package main import ( + "context" + "fmt" + "log" + "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" ) func main() { + ctx := context.Background() client := ometa.NewClient( "http://localhost:8585", ometa.WithToken(""), ) + + for table, err := range client.Tables.List(ctx, nil) { + if err != nil { + log.Fatal(err) + } + fmt.Println(table.Name) + } } ``` @@ -56,6 +68,8 @@ You can customize the client behavior using functional options: Requests that return HTTP `429` (Too Many Requests) or `504` (Gateway Timeout) are automatically retried. ```go +import "time" + client := ometa.NewClient( "http://localhost:8585", ometa.WithToken(""), @@ -92,6 +106,8 @@ Every service provides the following methods: The `List` method returns a Go iterator that handles pagination automatically: ```go +ctx := context.Background() + for table, err := range client.Tables.List(ctx, nil) { if err != nil { log.Fatal(err) @@ -106,10 +122,10 @@ Retrieve a single entity by UUID or by Fully Qualified Name: ```go // By ID -table, err := client.Tables.GetByID(ctx, "", nil) +tableByID, err := client.Tables.GetByID(ctx, "", nil) // By Fully Qualified Name -table, err := client.Tables.GetByName(ctx, "sample_data.ecommerce_db.shopify.dim_customer", nil) +tableByName, err := client.Tables.GetByName(ctx, "sample_data.ecommerce_db.shopify.dim_customer", nil) ``` ### Create an Entity @@ -161,7 +177,7 @@ Delete by UUID or by Fully Qualified Name: err := client.Tables.Delete(ctx, "", nil) // By Fully Qualified Name with hard delete -err := client.Tables.DeleteByName(ctx, "sample_data.ecommerce_db.shopify.my_table", +err = client.Tables.DeleteByName(ctx, "sample_data.ecommerce_db.shopify.my_table", &ometa.DeleteTable1Params{HardDelete: ometa.Bool(true)}, ) ``` @@ -181,8 +197,9 @@ table, err := client.Tables.GetVersion(ctx, "", "0.2") ### Restore a Soft-Deleted Entity ```go -table, err := client.Tables.Restore(ctx, &ometa.RestoreEntity{ - Id: ometa.Str(""), +// table is a *ometa.Table you retrieved earlier +restored, err := client.Tables.Restore(ctx, &ometa.RestoreEntity{ + Id: table.Id, }) ``` diff --git a/v2.1.x-SNAPSHOT/sdk/java.mdx b/v2.1.x-SNAPSHOT/sdk/java.mdx index 727aa1d18..a53d0e58c 100644 --- a/v2.1.x-SNAPSHOT/sdk/java.mdx +++ b/v2.1.x-SNAPSHOT/sdk/java.mdx @@ -24,204 +24,148 @@ You can add the below Maven Dependency for the OpenMetadata Java SDK. ``` -## Establish OpenMetadata Server Connection +## Connect to the OpenMetadata Server -To create OpenMetadata Gateway, you will need to establish a connection with *OpenMetadata Server*. The following -inputs will be needed for the same. -* Host Port: The url on which your instance of OpenMetadata is up and running. -* ApiVersion: The value will be "v1". -* Auth Provider: Provide the auth provider with which you need to configure. -* Security Config: Provide the config for the selected auth provider. +To connect to your OpenMetadata server, you need: -```java -OpenMetadataConnection server = new OpenMetadataConnection(); -server.setHostPort("http://localhost:{port}}/api"); -server.setApiVersion("v1"); -server.setAuthProvider(OpenMetadataConnection.AuthProvider.{auth_provider}); -server.setSecurityConfig({security_client_config}); -``` - -## Create OpenMetadata Gateway - -Once the connection details are provided, you can create an OpenMetadata Gateway -using the following piece of code. +* Server URL: The URL where your OpenMetadata instance is running, ending in `/api`. For example, `http://localhost:8585/api`. +* Access token: A JSON Web Token (JWT) for a user or bot. See [Authentication](/v2.1.x-SNAPSHOT/api-reference/authentication) to learn how to get one. ```java -// OpenMetadata Gateway -OpenMetadata openMetadataGateway = new OpenMetadata(server); -``` +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -## Use Java SDK without Authentication -To use the Java SDK without any authentication, you can use `NoOpAuthenticationProvider.java`. \ +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .build(); -```java -NoOpAuthenticationProvider noOpAuthenticationProvider = new NoOpAuthenticationProvider(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` -Establish the [OpenMetadata Server Connection](#establish-openmetadata-server-connection) and provide `noOpAuthenticationProvider` in the config. +Tune the connection with these options. Timeouts are in milliseconds, and `header` adds a custom header to every request: ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.NO_AUTH); +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("{jwt_token}") + .connectTimeout(10000) + .readTimeout(30000) + .header("X-Request-Source", "my-app") + .build(); ``` -## Use Java SDK with Authentication. +## Authenticate with a JWT Token -The OpenMetadata Java SDK supports several auth providers: -* [Google](#google) -* [Okta](#okta) -* [Auth0](#auth0) -* [Azure](#azure) -* [OpenMetadata](#openmetadata) +The Java SDK authenticates with a JWT access token that you pass to `accessToken(...)`. This is the same for every sign-in method on your OpenMetadata server, including Google, Okta, Auth0, Azure, and custom OpenID Connect (OIDC). Generate a bot token or a personal access token in OpenMetadata and use it here. -Apart from the above mentioned auth providers, OpenMetadata Java SDK also supports [Custom OIDC](#custom-oidc). +If your server doesn't require authentication, leave out `accessToken(...)`. -### Google -To set up Google as the auth provider, the following details are required: -* Secret Key: Pass the JSON file generated in [Create Service Account](/v2.1.x-SNAPSHOT/deployment/security/google) as the secretKey. +## Use the Fluent API -```java -GoogleSSOClientConfig googleSSOClientConfig = new GoogleSSOClientConfig(); -ssoConfig.setAudience("https://www.googleapis.com/oauth2/v4/token"); -ssoConfig.setSecretKey("{secret_key.json}"); -``` +The fluent classes, such as `Tables`, `Users`, and `Teams`, work with a default client. Register your client once with `OM.init`, and the fluent classes use it: -Provide the Google config while creating the [server connection](#establish-openmetadata-server-connection). ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.GOOGLE); -server.setSecurityConfig(googleSSOClientConfig); +import org.openmetadata.sdk.OM; +import org.openmetadata.sdk.fluent.Tables; -``` +OM.init(client); -### Okta -To set up Okta as the auth provider, the following details should be provided: -* Client ID: Provide the client ID for the service application -* Org URL: It is the same as the ISSUER_URL with v1/token. It is recommended to use a separate authorization server for different applications, rather than using the default authorization server. -* Private Key: Use the Public/Private Key Pair that was generated while [Creating the Service Application](/v2.1.x-SNAPSHOT/deployment/security/okta#okta-sso). When copy-pasting the keys ensure that there are no additional codes and that it is a JSON compatible string. -* Email: Enter the email address -* Scopes: Add the details of the scope created in the Authorization Server. Enter the name of the default scope created. +// Find a table by its fully qualified name +var table = Tables.findByName("mysql-prod.employees.public.employees") + .includeOwners() + .includeTags() + .fetch() + .get(); -```java -OktaSSOClientConfig oktaSSOClientConfig = new OktaSSOClientConfig(); -oktaSSOClientConfig.setClientId("{client_id}"); -oktaSSOClientConfig.setOrgURL("{org_url}/v1/token"); -oktaSSOClientConfig.setPrivateKey("{public/private keypair}"); -oktaSSOClientConfig.setEmail("{email}"); -oktaSSOClientConfig.setScopes({scope_list}); +// Update its description +Tables.findByName("mysql-prod.employees.public.employees") + .fetch() + .withDescription("Updated description") + .save(); ``` -Provide the Okta config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OKTA); -server.setSecurityConfig(oktaSSOClientConfig); -``` +## Use the Service Clients -### Auth0 -To set up Auth0 as the auth provider, the following details are required: -* Client ID: Provide the client ID for the service application -* Secret Key: Provide the client secret. -* Domain: Provide the Auth0 domain. For example `test.us.auth0.com` +Every entity type has a service on the client, such as `client.tables()`, `client.users()`, and `client.dashboards()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. Below are some examples: ```java -Auth0SSOClientConfig auth0SSOClientConfig = new Auth0SSOClientConfig(); -auth0SSOClientConfig.setClientId("{client_id}"); -auth0SSOClientConfig.setSecretKey("{secret_key}"); -auth0SSOClientConfig.setDomain("{domain}"); -``` -Provide the Auth0 config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AUTH_0); -server.setSecurityConfig(auth0SSOClientConfig); -``` +import org.openmetadata.sdk.models.ListParams; -### Azure -To set up Azure as the auth provider, the following details should be provided: -* Client ID: The Application (Client) ID is displayed in the Overview section of the registered application. -* Client Secret: The clientSecret can be accessed from the Certificates & secret section of the application. -* Authority: Use your Microsoft Entra tenant authority. See [Microsoft's OpenID Connect documentation](https://learn.microsoft.com/en-us/entra/identity-platform/v2-protocols-oidc) for the endpoint format. -* Scopes: Add the details of the scope created. +// Tables +var tables = client.tables().list(new ListParams().setLimit(10)); +for (var table : tables.getData()) { + System.out.println(table.getFullyQualifiedName()); +} -```java -AzureSSOClientConfig azureSSOClientConfig = new AzureSSOClientConfig(); -azureSSOClientConfig.setClientId("{client_id}"); -azureSSOClientConfig.setClientSecret("{client_secret}"); -azureSSOClientConfig.setAuthority("{authority}"); -azureSSOClientConfig.setScopes({scope_list}); -``` -Provide the Azure config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.AZURE); -server.setSecurityConfig(azureSSOClientConfig); +// Users +var users = client.users().list(new ListParams().setLimit(10)); + +// Dashboards +var dashboards = client.dashboards().list(new ListParams().setLimit(10)); ``` -### OpenMetadata -To set up OpenMetadata as the auth provider, the following details should be provided: -* JWT Token: Provide the JWT Token. For example `eyJraWQiOiJHYjM4OWEtOWY3Ni1nZGpzLWE5Mmo....XN0aW9uLWJvdEBvcGVubWV0YWRhdGEub3JnIn0.Ku_FHGIS3Id3ARusMaXZDYKcq...Ztap9KDU7nZilNT2Bq-o75aIsgKKmtSuVdBTzpFK8aLGLmRp_8J007t-kpcjIW7Qf0l4...dGb0QqhoZin0JA` +The following examples show how to call an API: + +* Create a table ```java -OpenMetadataJWTClientConfig openMetadataJWTClientConfig = new OpenMetadataJWTClientConfig(); -openMetadataJWTClientConfig.setJwtToken("{jwt_token}"); -``` -Provide the OpenMetadata config while creating the [server connection](#establish-openmetadata-server-connection). -```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.OPENMETADATA); -server.setSecurityConfig(openMetadataJWTClientConfig); -``` +import java.util.List; +import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; -### Custom OIDC -To set up Custom auth provider. The following details are required: -* Client ID: Provide the client ID of the preferred auth provider -* Client Secret: Provide the client secret of your preferred auth provider -* Token Endpoint: Provide the token endpoint of your preferred auth provider +CreateTable request = new CreateTable() + .withName("orders") + .withDatabaseSchema("mysql-prod.employees.public") + .withDescription("Orders placed by customers") + .withColumns(List.of( + new Column() + .withName("order_id") + .withDataType(ColumnDataType.BIGINT) + .withDescription("Primary key"), + new Column() + .withName("status") + .withDataType(ColumnDataType.VARCHAR) + .withDataLength(50))); -```java -CustomOIDCSSOClientConfig customOIDCSSOClientConfig = new CustomOIDCSSOClientConfig(); -config.setClientId("{client_id}"); -config.setSecretKey("{client_secret}"); -config.setTokenEndpoint("{token_endpoint}"); +var table = client.tables().create(request); ``` -Provide the custom auth provider config while creating the [server connection](#establish-openmetadata-server-connection). +* Get a table by fully qualified name + ```java -server.setAuthProvider(OpenMetadataServerConnection.AuthProvider.CUSTOM_OIDC); -server.setSecurityConfig(customOIDCSSOClientConfig); +var table = client.tables().getByName("mysql-prod.employees.public.employees", "columns,owners"); ``` -## How to Use APIs Using the Java SDK -You can use an API from the [OpenMetadata Gateway](#create-openmetadata-gateway). -Using OpenMetadata Gateway, you will need to build the client by providing the `class` of the respected API. -Below are some examples: +* Search + ```java -// Dashboards API -DashboardsApi dashboardApi = openMetadataGateway.buildClient(DashboardsApi.class); +String response = client.search() + .query("customer") + .index("table_search_index") + .size(10) + .execute(); +``` -// Tables API -TablesApi tablesApiClient = openMetadataGateway.buildClient(TablesApi.class); +The search call returns the raw JSON response from the server as a string. -// Users API -UsersApi usersApi = openMetadataGateway.buildClient(UsersApi.class); +## Handle Errors -// Locations API -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -``` +When the server returns an error, the SDK throws an `OpenMetadataException`. Use `getStatusCode()` to see which error it was: -Please refer to the examples to access an API: -* Tables API ```java -TablesApi tablesApi = openMetadataGateway.buildClient(TablesApi.class); -tablesApi.addLocationToTable("{table_id}", "{location_id}"); -``` -* Location API -```java -LocationsApi locationsApi = openMetadataGateway.buildClient(LocationsApi.class); -CreateLocation createLocation = new CreateLocation(); -Location location = locationsApi.createLocation(createLocation); -``` +import org.openmetadata.sdk.exceptions.OpenMetadataException; -* Elastic Search API -```java -ElasticSearchApi esApi = openMetadataGateway.buildClient(ElasticSearchApi.class); -Response response = esApi.searchEntitiesWithQuery("", "pipeline_search_index", false, 0, 0, null, null, true, "{\"query\":{\"bool\":{}}}", null, false, null ); -String data = IOUtils.toString(response.body().asInputStream(), Charsets.UTF_8); +try { + var table = client.tables().getByName("mysql-prod.employees.public.missing"); +} catch (OpenMetadataException e) { + if (e.getStatusCode() == 404) { + System.out.println("Table not found"); + } else { + System.out.println("Request failed: " + e.getMessage()); + } +} ``` ## More examples diff --git a/v2.1.x-SNAPSHOT/sdk/java/info.mdx b/v2.1.x-SNAPSHOT/sdk/java/info.mdx index b81f01cc0..07c3b9914 100644 --- a/v2.1.x-SNAPSHOT/sdk/java/info.mdx +++ b/v2.1.x-SNAPSHOT/sdk/java/info.mdx @@ -6,7 +6,7 @@ sidebarTitle: Java SDK Info # Java SDK -The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers comprehensive support for entity management, authentication, and integration with enterprise Java applications. +The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers support for entity management, search, lineage, and authentication with a JWT token. ## Installation @@ -35,85 +35,87 @@ implementation 'org.open-metadata:openmetadata-sdk:2.0.5' ### Basic Connection ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; -import org.openmetadata.client.auth.BasicAuthProvider; - -// Create client with basic authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new BasicAuthProvider("admin", "admin")) +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.network.HttpMethod; + +// Create a client with a JWT token +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") .build(); -// Health check -if (client.healthCheck()) { - System.out.println("Successfully connected to OpenMetadata!"); -} -``` - -### JWT Authentication - -```java -import org.openmetadata.client.auth.JWTAuthProvider; +OpenMetadataClient client = new OpenMetadataClient(config); -// Create client with JWT authentication -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(new JWTAuthProvider("your-jwt-token")) - .build(); +// Check the connection by reading the server version +String version = client.getHttpClient() + .executeForString(HttpMethod.GET, "/v1/system/version", null); +System.out.println("Connected to OpenMetadata: " + version); ``` +For more information about getting a token, see [Authentication](/v2.1.x-SNAPSHOT/api-reference/authentication). + ## Core Functionality ### Working with Entities +Every entity type has a service on the client, such as `client.databaseServices()`, `client.tables()`, and `client.users()`. These services offer methods such as `create`, `get`, `getByName`, `list`, `update`, `delete`, and `restore`. + #### Database Services ```java -import org.openmetadata.schema.entity.services.DatabaseService; import org.openmetadata.schema.api.services.CreateDatabaseService; +import org.openmetadata.schema.api.services.DatabaseConnection; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.schema.services.connections.database.MysqlConnection; +import org.openmetadata.sdk.models.ListParams; -// List all database services -List services = client.listDatabaseServices(); -System.out.println("Found " + services.size() + " database services"); +// List database services +var services = client.databaseServices().list(new ListParams().setLimit(50)); +System.out.println("Found " + services.getData().size() + " database services"); // Get specific service by name -DatabaseService service = client.getDatabaseServiceByName("mysql-prod"); +DatabaseService service = client.databaseServices().getByName("mysql-prod"); // Create new database service CreateDatabaseService createRequest = new CreateDatabaseService() .withName("new-mysql-service") - .withServiceType(DatabaseServiceType.MYSQL) - .withDescription("Production MySQL database"); - -DatabaseService newService = client.createDatabaseService(createRequest); + .withServiceType(CreateDatabaseService.DatabaseServiceType.Mysql) + .withDescription("Production MySQL database") + .withConnection(new DatabaseConnection().withConfig( + new MysqlConnection() + .withHostPort("localhost:3306") + .withUsername("openmetadata_user"))); + +DatabaseService newService = client.databaseServices().create(createRequest); ``` #### Tables ```java -import org.openmetadata.schema.entity.data.Table; +import java.util.List; import org.openmetadata.schema.api.data.CreateTable; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.type.Column; +import org.openmetadata.schema.type.ColumnDataType; +import org.openmetadata.sdk.models.ListParams; // Get table by fully qualified name -Table table = client.getTableByName("mysql-prod.employees.employees"); -if (table != null) { - System.out.println("Table: " + table.getName()); - System.out.println("Columns: " + table.getColumns().size()); -} +Table table = client.tables().getByName("mysql-prod.employees.public.employees", "columns"); +System.out.println("Table: " + table.getName()); +System.out.println("Columns: " + table.getColumns().size()); -// List tables with pagination -EntityList
tables = client.listTables( - 10, // limit - null, // after cursor - "mysql-prod" // service filter -); +// List tables in a schema with pagination +var tables = client.tables().list( + new ListParams() + .setLimit(10) + .addFilter("databaseSchema", "mysql-prod.employees.public")); // Create table CreateTable createTable = new CreateTable() .withName("new_table") - .withDatabaseSchema("mysql-prod.employees") - .withColumns(Arrays.asList( + .withDatabaseSchema("mysql-prod.employees.public") + .withColumns(List.of( new Column() .withName("id") .withDataType(ColumnDataType.BIGINT) @@ -125,7 +127,7 @@ CreateTable createTable = new CreateTable() .withDescription("Employee name") )); -Table newTable = client.createTable(createTable); +Table newTable = client.tables().create(createTable); ``` ### Entity Operations @@ -133,111 +135,83 @@ Table newTable = client.createTable(createTable); #### CRUD Operations ```java -// Create or Update -DatabaseService service = client.createOrUpdateDatabaseService(createRequest); +import java.util.Map; +import java.util.UUID; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.network.HttpMethod; + +// Create or update a table +Table table = client.tables().createOrUpdate(createTable); + +// Create or update a database service +DatabaseService service = client.getHttpClient().execute( + HttpMethod.PUT, "/v1/services/databaseServices", createRequest, DatabaseService.class); // Get by ID -UUID serviceId = UUID.fromString("service-uuid-here"); -DatabaseService service = client.getDatabaseServiceById(serviceId); +UUID serviceId = service.getId(); +DatabaseService sameService = client.databaseServices().get(serviceId); // Delete -client.deleteDatabaseService(serviceId, false); // soft delete -client.deleteDatabaseService(serviceId, true); // hard delete +client.databaseServices().delete(serviceId.toString()); // soft delete +client.databaseServices().delete(serviceId.toString(), Map.of("hardDelete", "true")); // hard delete ``` #### Search and Filtering ```java -// Search tables -SearchRequest searchRequest = new SearchRequest() - .withQuery("customer") - .withEntityTypes(Arrays.asList("table")) - .withSize(50); - -SearchResponse results = client.search(searchRequest); -for (SearchHit hit : results.getHits()) { - System.out.println("Found: " + hit.getDisplayName()); -} +import org.openmetadata.sdk.models.ListParams; + +// Search tables. The response is the raw JSON from the server. +String results = client.search() + .query("customer") + .index("table_search_index") + .size(50) + .execute(); +System.out.println(results); // Advanced filtering -EntityList
customerTables = client.listTables( - 100, - null, - Map.of( - "service", "mysql-prod", - "database", "ecommerce" - ) -); +var customerTables = client.tables().list( + new ListParams() + .setLimit(100) + .addFilter("database", "mysql-prod.ecommerce")); ``` ## Advanced Features -### Authentication Providers - -#### Custom Authentication - -```java -import org.openmetadata.client.auth.AuthProvider; - -public class CustomAuthProvider implements AuthProvider { - private String customToken; - - public CustomAuthProvider(String token) { - this.customToken = token; - } - - @Override - public String getAuthToken() { - return "Bearer " + customToken; - } - - @Override - public void refresh() { - // Implement token refresh logic - } -} - -// Use custom auth provider -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(new CustomAuthProvider("custom-token")) - .build(); -``` +### Authentication -#### OAuth 2.0 Integration +The Java SDK authenticates with a JWT access token. When your token changes, create a new client with the new token: ```java -import org.openmetadata.client.auth.OAuth2AuthProvider; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -OAuth2AuthProvider authProvider = OAuth2AuthProvider.builder() - .clientId("your-client-id") - .clientSecret("your-client-secret") - .tokenUrl("https://auth.provider.com/oauth/token") - .scopes(Arrays.asList("read", "write")) - .build(); +String newToken = "your-new-jwt-token"; -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("https://your-instance.com/api") - .authProvider(authProvider) - .build(); +OpenMetadataClient client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl("https://your-instance.com/api") + .accessToken(newToken) + .build()); ``` ### Error Handling ```java -import org.openmetadata.client.exception.OpenMetadataException; +import org.openmetadata.sdk.exceptions.OpenMetadataException; try { - Table table = client.getTableByName("non-existent-table"); + var table = client.tables().getByName("non-existent-table"); } catch (OpenMetadataException e) { - switch (e.getErrorCode()) { - case NOT_FOUND: + switch (e.getStatusCode()) { + case 404: System.out.println("Table not found"); break; - case UNAUTHORIZED: + case 401: System.out.println("Authentication failed"); break; - case FORBIDDEN: + case 403: System.out.println("Access denied"); break; default: @@ -248,15 +222,22 @@ try { ### Async Operations +The service methods are blocking. To run them in parallel, wrap them in a `CompletableFuture`: + ```java +import java.util.List; import java.util.concurrent.CompletableFuture; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.schema.entity.services.DatabaseService; +import org.openmetadata.sdk.models.ListParams; -// Async client operations CompletableFuture> servicesFuture = - client.listDatabaseServicesAsync(); + CompletableFuture.supplyAsync( + () -> client.databaseServices().list(new ListParams().setLimit(50)).getData()); CompletableFuture
tableFuture = - client.getTableByNameAsync("mysql-prod.employees.employees"); + CompletableFuture.supplyAsync( + () -> client.tables().getByName("mysql-prod.employees.public.employees", "columns")); // Combine async operations CompletableFuture combinedFuture = CompletableFuture.allOf( @@ -280,39 +261,19 @@ CompletableFuture combinedFuture = CompletableFuture.allOf( ### Client Configuration ```java -import org.openmetadata.client.config.ClientConfig; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; -ClientConfig config = ClientConfig.builder() - .connectionTimeout(30000) // 30 seconds +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .connectTimeout(30000) // 30 seconds .readTimeout(60000) // 60 seconds - .retryCount(3) // Retry failed requests 3 times - .enableLogging(true) // Enable request/response logging - .enableMetrics(true) // Enable client metrics - .userAgent("MyApp/1.0") // Custom user agent + .writeTimeout(60000) // 60 seconds + .header("User-Agent", "MyApp/1.0") // Custom header on every request .build(); -OpenMetadataClient client = OpenMetadataClient.builder() - .baseUrl("http://localhost:8585/api") - .authProvider(authProvider) - .config(config) - .build(); -``` - -### Connection Pooling - -```java -import org.openmetadata.client.config.ConnectionPoolConfig; - -ConnectionPoolConfig poolConfig = ConnectionPoolConfig.builder() - .maxTotal(100) // Maximum total connections - .maxPerRoute(20) // Maximum connections per route - .connectionTTL(300000) // Connection TTL in milliseconds - .validateAfterInactivity(10000) // Validate connections after 10s - .build(); - -ClientConfig config = ClientConfig.builder() - .connectionPoolConfig(poolConfig) - .build(); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ## Common Use Cases @@ -320,15 +281,26 @@ ClientConfig config = ClientConfig.builder() ### Metadata Discovery ```java -// Discover all tables in a service -String serviceName = "mysql-prod"; +import java.util.ArrayList; +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + +// Discover all tables in a schema +String schemaName = "mysql-prod.employees.public"; List
allTables = new ArrayList<>(); String after = null; do { - EntityList
batch = client.listTables(100, after, serviceName); + var params = new ListParams() + .setLimit(100) + .addFilter("databaseSchema", schemaName); + if (after != null) { + params.setAfter(after); + } + var batch = client.tables().list(params); allTables.addAll(batch.getData()); - after = batch.getAfter(); + after = batch.getPaging().getAfter(); } while (after != null); System.out.println("Discovered " + allTables.size() + " tables"); @@ -337,17 +309,19 @@ System.out.println("Discovered " + allTables.size() + " tables"); ### Bulk Operations ```java +import java.util.List; +import org.openmetadata.schema.entity.data.Table; +import org.openmetadata.sdk.models.ListParams; + // Bulk update table descriptions -List
tables = client.listAllTablesInService("mysql-prod"); +List
tables = client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", "mysql-prod.employees.public")) + .getData(); for (Table table : tables) { if (table.getDescription() == null || table.getDescription().isEmpty()) { - CreateTable updateRequest = new CreateTable() - .withName(table.getName()) - .withDatabaseSchema(table.getDatabaseSchema().getFullyQualifiedName()) - .withDescription("Auto-generated description for " + table.getName()); - - client.createOrUpdateTable(updateRequest); + table.setDescription("Auto-generated description for " + table.getName()); + client.tables().update(table.getId().toString(), table); } } ``` @@ -355,87 +329,61 @@ for (Table table : tables) { ### Lineage Operations ```java -import org.openmetadata.schema.type.EntityLineage; - -// Get table lineage -EntityLineage lineage = client.getTableLineage( - "mysql-prod.employees.employees", - 1, // upstream depth - 1 // downstream depth +// Get table lineage as JSON (1 hop upstream, 1 hop downstream) +String lineage = client.lineage().getLineageByName( + "table", + "mysql-prod.employees.public.employees", + "1", // upstream depth + "1" // downstream depth ); -System.out.println("Upstream entities: " + lineage.getUpstreamEdges().size()); -System.out.println("Downstream entities: " + lineage.getDownstreamEdges().size()); +System.out.println(lineage); ``` -## Spring Boot Integration +For more information about the fluent API for lineage, see [Java SDK for Lineage](/v2.1.x-SNAPSHOT/api-reference/sdk/java/lineage). -### Configuration Class +## Use the Client in Your Application -```java -@Configuration -@EnableConfigurationProperties(OpenMetadataProperties.class) -public class OpenMetadataConfig { - - @Bean - public OpenMetadataClient openMetadataClient(OpenMetadataProperties properties) { - return OpenMetadataClient.builder() - .baseUrl(properties.getBaseUrl()) - .authProvider(new JWTAuthProvider(properties.getJwtToken())) - .build(); - } -} - -@ConfigurationProperties(prefix = "openmetadata") -@Data -public class OpenMetadataProperties { - private String baseUrl; - private String jwtToken; -} -``` - -### Service Layer +Create one `OpenMetadataClient` and share it across your application. If you use a framework such as Spring Boot, register the client as a singleton bean. ```java -@Service -public class MetadataService { +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; +import org.openmetadata.sdk.models.ListParams; - private final OpenMetadataClient client; +class MetadataService { - public MetadataService(OpenMetadataClient client) { - this.client = client; - } + private final OpenMetadataClient client; - public List
getTablesForService(String serviceName) { - return client.listAllTablesInService(serviceName); + public MetadataService(String baseUrl, String jwtToken) { + this.client = new OpenMetadataClient( + OpenMetadataConfig.builder() + .serverUrl(baseUrl) + .accessToken(jwtToken) + .build()); } - public Table createTable(CreateTableRequest request) { - CreateTable createTable = new CreateTable() - .withName(request.getName()) - .withDatabaseSchema(request.getSchemaFqn()) - .withColumns(request.getColumns()); - - return client.createTable(createTable); + public java.util.List getTablesForSchema(String schemaFqn) { + return client.tables() + .list(new ListParams().setLimit(100).addFilter("databaseSchema", schemaFqn)) + .getData(); } } ``` ## Best Practices -1. **Resource Management**: Always close clients when done -2. **Connection Pooling**: Use connection pooling for high-throughput applications -3. **Error Handling**: Implement proper retry logic and error handling -4. **Authentication**: Use secure authentication methods in production -5. **Async Operations**: Use async methods for better performance in concurrent scenarios -6. **Pagination**: Always handle pagination for large datasets -7. **Caching**: Implement caching for frequently accessed entities +- **Reuse the client**: Create one client and share it instead of creating a new one per request. +- **Handle errors**: Catch `OpenMetadataException` and check the status code. +- **Protect authentication**: Keep your JWT token in a secret store, not in source code. +- **Use async operations**: Wrap calls in `CompletableFuture` for better performance in concurrent scenarios. +- **Handle pagination**: Always handle pagination for large datasets. +- **Cache entities**: Implement caching for frequently accessed entities. ## Performance Tips -- Use batch operations when possible -- Implement connection pooling for high-concurrency applications -- Cache frequently accessed metadata -- Use async operations for better throughput -- Specify only required fields when fetching entities -- Implement proper retry strategies with exponential backoff \ No newline at end of file +- Create one client and reuse it. +- Cache frequently accessed metadata. +- Run independent calls in parallel with `CompletableFuture`. +- Specify only required fields when fetching entities. +- Use filters to narrow lists before you read them. diff --git a/v2.1.x-SNAPSHOT/sdk/overview.mdx b/v2.1.x-SNAPSHOT/sdk/overview.mdx index fc2135599..f3bf08897 100644 --- a/v2.1.x-SNAPSHOT/sdk/overview.mdx +++ b/v2.1.x-SNAPSHOT/sdk/overview.mdx @@ -2,6 +2,8 @@ title: OpenMetadata SDKs description: 'Official client libraries for Python, Java, and Go to integrate with OpenMetadata APIs. Type-safe, full-featured SDKs for metadata management and automation.' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # OpenMetadata SDKs @@ -25,7 +27,7 @@ Official client libraries provide type-safe, full-featured access to OpenMetadat - Full-featured Python client + Original Client and SDK 2.0 (`metadata.sdk`) Enterprise Java integration @@ -44,15 +46,24 @@ Perfect for: - ML pipeline automation - Data quality automation +SDK 2.0 (`metadata.sdk`, OpenMetadata 1.10.0 and later): + + + +Original client: + ```python from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( OpenMetadataConnection, ) +from metadata.generated.schema.security.client.openMetadataJWTClientConfig import ( + OpenMetadataJWTClientConfig, +) from metadata.ingestion.ometa.ometa_api import OpenMetadata server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -69,13 +80,15 @@ Perfect for: - Legacy system integration ```java -import org.openmetadata.client.OpenMetadataClient; -import org.openmetadata.client.model.*; +import org.openmetadata.sdk.client.OpenMetadataClient; +import org.openmetadata.sdk.config.OpenMetadataConfig; + +OpenMetadataConfig config = OpenMetadataConfig.builder() + .serverUrl("http://localhost:8585/api") + .accessToken("your-jwt-token") + .build(); -OpenMetadataClient client = new OpenMetadataClient( - "http://localhost:8585/api", - "your-jwt-token" -); +OpenMetadataClient client = new OpenMetadataClient(config); ``` ### Go SDK @@ -86,11 +99,11 @@ Perfect for: - High-performance services ```go -import "github.com/open-metadata/openmetadata-go-client" +import "github.com/open-metadata/openmetadata-sdk/openmetadata-go-client/pkg/ometa" -client := openmetadata.NewClient( - "http://localhost:8585/api", - "your-jwt-token", +client := ometa.NewClient( + "http://localhost:8585", + ometa.WithToken("your-jwt-token"), ) ``` diff --git a/v2.1.x-SNAPSHOT/sdk/python.mdx b/v2.1.x-SNAPSHOT/sdk/python.mdx index bafcc3978..8d58ab8ab 100644 --- a/v2.1.x-SNAPSHOT/sdk/python.mdx +++ b/v2.1.x-SNAPSHOT/sdk/python.mdx @@ -3,6 +3,8 @@ title: Python SDK | OpenMetadata Python SDK Documentation description: Master OpenMetadata'sPython SDK with comprehensive documentation, code examples, and API guides. Build powerful data discovery and governance solutions. sidebarTitle: Overview --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -17,7 +19,7 @@ We are now going to present a high-level Python API as a type-safe and gentle wr - Make sure to use the same `openmetadata-ingestion` version as your server version. For example, if you have the OpenMetadata server at version 2.0.5, you need to install: -```python +```bash pip install "openmetadata-ingestion~=2.0.5.0" ``` @@ -30,7 +32,15 @@ In the [OpenMetadata Design](/v2.1.x-SNAPSHOT/developers/architecture), we have This means that whenever we need to interact with the metadata system or develop a new connector or logic, we have to make sure that we pass the proper inputs and handle the types of outputs. -## Introducing the Python API + + +## SDK 2.0 Quick Start + +Connect with `configure()`, then create, update, and delete a table: + + + +## Introducing the Python API (Original Client) Let's suppose that we have our local OpenMetadata server running at `http:localhost:8585`. We can play with it with simple `cURL` or `httpie` commands, and if we just want to take a look at the Entity instances we have lying around, that might probably be enough. However, let's imagine that we want to create or update an ML Model Entity with a `PUT`. To do so, we need to make sure that we are providing a proper JSON, covering all the attributes and types required by the Entity definition. @@ -320,8 +330,8 @@ class CreateDatabaseRequest(BaseModel): None, description='Description of the database instance. What it has and how to use it.', ) - owner: Optional[entityReference.EntityReference] = Field( - None, description='Owner of this database' + owners: Optional[entityReferenceList.EntityReferenceList] = Field( + None, description='Owners of this database' ) service: basic.FullyQualifiedEntityName = Field( ..., @@ -335,7 +345,7 @@ class CreateDatabaseRequest(BaseModel): Note how the only non-optional fields are `name` and `service`. The type of `service`, however, is `FullyQualifiedEntityName`. This is expected, as there we need to pass the information of an existing Entity. In our case, the `fullyQualifiedName` of the `DatabaseService` we just created. -In the case of the `owner` field, repeating the exercise and reviewing the required fields to instantiate an `EntityReference` we notice how we need to pass an `id: uuid.UUID` and `type: str`. There we need to specify the `id` and `type` of an `User`. +The `owners` field takes a list of `EntityReference`. To instantiate an `EntityReference`, pass an `id: uuid.UUID` and `type: str`. Specify the `id` and `type` of a `User`. **Querying by name** @@ -404,8 +414,8 @@ Let's now update the `Table` by adding an owner. This will require us to create First, make sure that no owner has been set during the creation: ```python -print(table_entity.owner) -# None +print(table_entity.owners) +# root=[] ``` Now, create a `User`: @@ -418,19 +428,19 @@ user = metadata.create_or_update( ) ``` -Update our instance of `create_table` to add the `owner` field (we need to use the `Create` class as we'll run a `PUT`), and update the Entity: +Update your `create_table` instance to add the `owners` field. Use the `Create` class, because this runs a `PUT`. Then update the Entity: ```python from metadata.generated.schema.type.entityReference import EntityReference -create_table.owner = EntityReference(id=user.id, type="user") +create_table.owners = [EntityReference(id=user.id, type="user")] updated_table_entity = metadata.create_or_update(create_table) -print(updated_table_entity.owner) -# EntityReference(id=Uuid(__root__=UUID('48793f0c-5308-45c1-9bf4-06a82c8d7bf9')), type='user', name='random-user', description=None, displayName=None, href=Href(__root__=AnyUrl('http://localhost:8585/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9', scheme='http', host='localhost', host_type='int_domain', port='8585', path='/api/v1/users/48793f0c-5308-45c1-9bf4-06a82c8d7bf9'))) +print(updated_table_entity.owners.root[0].name) +# random-user ``` -If we did not save the `updated_table_entity` variable, we should need to query it to review the `owner` field. We can run the `get_by_name` using the proper FQN definition for `Table`s: +If you didn't save the `updated_table_entity` variable, query it to review the `owners` field. Run `get_by_name` with the FQN of the table: ```python my_table = metadata.get_by_name(entity=Table, fqn="test-service-table.test-db.test-schema.test") diff --git a/v2.1.x-SNAPSHOT/sdk/python/api-reference.mdx b/v2.1.x-SNAPSHOT/sdk/python/api-reference.mdx index 6767aff5d..1ff69898f 100644 --- a/v2.1.x-SNAPSHOT/sdk/python/api-reference.mdx +++ b/v2.1.x-SNAPSHOT/sdk/python/api-reference.mdx @@ -33,6 +33,7 @@ All entity types follow the same pattern: from metadata.sdk import Tables, Databases, DatabaseSchemas, DatabaseServices from metadata.sdk import Dashboards, Pipelines, MLModels, Tags, Classifications from metadata.sdk import Glossaries, GlossaryTerms, Users, Teams +from metadata.generated.schema.api.data.createTable import CreateTableRequest # Create entity = Tables.create(CreateTableRequest(...)) @@ -41,13 +42,18 @@ entity = Tables.create(CreateTableRequest(...)) entity = Tables.retrieve("uuid") entity = Tables.retrieve_by_name("service.db.schema.table", fields=["owners", "tags"]) -# List with auto-pagination -for table in Tables.list().auto_paging_iterable(): - print(table.name) +# List one page +page = Tables.list(limit=50) +for table in page.entities: + print(table.name.root) + +# List everything (follows the paging cursor for you) +for table in Tables.list_all(): + print(table.name.root) # Update entity.description = "Updated" -Tables.update(str(entity.id), entity) +Tables.update(entity) # Delete Tables.delete("uuid") @@ -68,7 +74,7 @@ Lineage.add_lineage( ) # Get lineage -lineage = Lineage.get_lineage("service.db.schema.table", upstream_depth=2, downstream_depth=2) +lineage = Lineage.get_lineage("service.db.schema.table", entity_type="table", upstream_depth=2, downstream_depth=2) ``` ### Error Handling @@ -78,9 +84,9 @@ from metadata.ingestion.ometa.client import APIError try: table = Tables.retrieve("table-id") -except APIError as e: - if e.status_code == 404: + if table is None: print("Not found") - elif e.status_code == 401: +except APIError as e: + if e.status_code == 401: print("Authentication failed") ``` diff --git a/v2.1.x-SNAPSHOT/sdk/python/overview.mdx b/v2.1.x-SNAPSHOT/sdk/python/overview.mdx index c193ace70..f65fdec21 100644 --- a/v2.1.x-SNAPSHOT/sdk/python/overview.mdx +++ b/v2.1.x-SNAPSHOT/sdk/python/overview.mdx @@ -2,6 +2,8 @@ title: Python SDK Overview description: 'Full-featured Python client library for OpenMetadata integration' --- +import PythonSdkChoice from '/snippets/sdk/python-sdk-choice.mdx' +import PythonSdk2Quickstart from '/snippets/sdk/python-sdk-2-quickstart.mdx' # Python SDK @@ -15,7 +17,17 @@ Install the OpenMetadata Python SDK using pip: pip install openmetadata-ingestion ``` -## Quick Start + + +## Quick Start: SDK 2.0 + +Connect with `configure()`, then create, update, and delete a table: + + + +## Quick Start: Original Client + +Connect with `OpenMetadataConnection`, then read and update entities: ### Basic Connection @@ -31,7 +43,7 @@ from metadata.generated.schema.security.client.openMetadataJWTClientConfig impor # Configure connection server_config = OpenMetadataConnection( hostPort="http://localhost:8585/api", - authProvider="collate", + authProvider="openmetadata", securityConfig=OpenMetadataJWTClientConfig( jwtToken="your-jwt-token" ), @@ -62,7 +74,7 @@ table = metadata.get_by_name( ) if table: - print(f"Table: {table.name}") + print(f"Table: {table.name.root}") print(f"Columns: {len(table.columns) if table.columns else 0}") ``` @@ -106,7 +118,7 @@ table = metadata.get_by_name( # List entities with pagination tables = metadata.list_entities( entity=Table, - fields=["owner", "tags"], + fields=["owners", "tags"], limit=50 ) ``` @@ -117,12 +129,12 @@ tables = metadata.list_entities( # Generator for large datasets all_tables = metadata.list_all_entities( entity=Table, - fields=["owner", "columns"], - params={"service": "your-service-name"} + fields=["owners", "columns"], + params={"databaseSchema": "your-service.your-database.your-schema"} ) for table in all_tables: - print(f"Processing table: {table.name}") + print(f"Processing table: {table.name.root}") ``` ### Entity References @@ -136,26 +148,26 @@ table_ref = metadata.get_entity_reference( # Use in other entity creation if table_ref: - print(f"Table reference: {table_ref.id}") + print(f"Table reference: {table_ref.id.root}") ``` ## Advanced Features -### Custom Configuration +### Validating a Custom Certificate Authority (CA) Certificate + +To trust a private CA, pass the path to its certificate in `sslConfig`: ```python -# Using custom authentication -from metadata.generated.schema.security.client.basicAuthenticationProvider import ( - BasicAuthenticationProvider, -) +from metadata.generated.schema.security.ssl.validateSSLClientConfig import ValidateSslClientConfig server_config = OpenMetadataConnection( hostPort="https://your-openmetadata-instance.com/api", - authProvider="basic", - securityConfig=BasicAuthenticationProvider( - username="your-username", - password="your-password" + authProvider="openmetadata", + securityConfig=OpenMetadataJWTClientConfig( + jwtToken="your-jwt-token" ), + verifySSL="validate", + sslConfig=ValidateSslClientConfig(caCertificate="/path/to/rootCert"), ) metadata = OpenMetadata(server_config) @@ -164,18 +176,10 @@ metadata = OpenMetadata(server_config) ### Error Handling ```python -from metadata.ingestion.ometa.ometa_api import ( - OpenMetadata, - InvalidEntityException, - EmptyPayloadException -) - -try: - table = metadata.get_by_name(entity=Table, fqn="non-existent-table") -except InvalidEntityException as e: - print(f"Invalid entity: {e}") -except EmptyPayloadException as e: - print(f"No data received: {e}") +# get_by_name returns None when the entity does not exist +table = metadata.get_by_name(entity=Table, fqn="non-existent-table") +if table is None: + print("Table not found") ``` ### Working with Versions @@ -200,11 +204,11 @@ all_tables = metadata.list_all_entities(entity=Table) matching_tables = [ table for table in all_tables - if "customer" in table.name.lower() + if "customer" in table.name.root.lower() ] for table in matching_tables: - print(f"Found customer table: {table.fullyQualifiedName}") + print(f"Found customer table: {table.fullyQualifiedName.root}") ``` ### Metadata Automation @@ -213,30 +217,28 @@ for table in matching_tables: # Bulk update table descriptions tables_to_update = metadata.list_all_entities( entity=Table, - params={"service": "production-db"} + params={"databaseSchema": "production-service.production-db.public"} ) for table in tables_to_update: if not table.description: # Update with a default description - table.description = f"Production table: {table.name}" + table.description = f"Production table: {table.name.root}" metadata.create_or_update(data=table) ``` ### Lineage Management ```python -from metadata.generated.schema.type.entityLineage import EntityLineage - -# Get table lineage +# Get table lineage (returns a dict) lineage = metadata.get_lineage_by_name( entity=Table, fqn="service.database.schema.table" ) if lineage: - print(f"Upstream entities: {len(lineage.upstreamEdges)}") - print(f"Downstream entities: {len(lineage.downstreamEdges)}") + print(f"Upstream edges: {len(lineage['upstreamEdges'])}") + print(f"Downstream edges: {len(lineage['downstreamEdges'])}") ``` ## API Reference