chore: import upstream snapshot with attribution
Integration Tests - MySQL + Elasticsearch / Detect Changes (push) Has been cancelled
Integration Tests - MySQL + Elasticsearch / integration-tests-mysql-elasticsearch (push) Has been cancelled
Integration Tests - PostgreSQL + Elasticsearch + Redis / Detect Changes (push) Has been cancelled
Integration Tests - PostgreSQL + Elasticsearch + Redis / integration-tests-postgres-elasticsearch-redis (push) Has been cancelled
Integration Tests - PostgreSQL + OpenSearch / Detect Changes (push) Has been cancelled
Integration Tests - PostgreSQL + OpenSearch / integration-tests-postgres-opensearch (push) Has been cancelled
Java Checkstyle / java-checkstyle (push) Has been cancelled
Maven Collate Tests / maven-collate-ci (push) Has been cancelled
OpenMetadata Service Unit Tests / openmetadata-service-unit-tests-status (push) Has been cancelled
Publish Package to Maven Central Repository / publish-maven-packages (push) Has been cancelled
OpenMetadata Service Unit Tests / Detect Changes (push) Has been cancelled
OpenMetadata Service Unit Tests / openmetadata-service-unit-tests (push) Has been cancelled
OpenMetadata Service Unit Tests / k8s_operator-unit-tests (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:35:45 +08:00
commit bf2343b7e4
16049 changed files with 3531137 additions and 0 deletions
@@ -0,0 +1 @@
lombok.log.fieldName = LOG
@@ -0,0 +1,268 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>openmetadata-clients</artifactId>
<groupId>org.open-metadata</groupId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>openmetadata-java-client</artifactId>
<name>OpenMetadata Java Client</name>
<properties>
<java.version>21</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<springfox-version>2.7.0</springfox-version>
<feign-version>13.5</feign-version>
<jackson-databind-nullable-version>0.2.6</jackson-databind-nullable-version>
<scribejava-apis-version>8.3.3</scribejava-apis-version>
<swagger-parser-version>2.1.23</swagger-parser-version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<maven-javadoc-plugin.version>3.6.0</maven-javadoc-plugin.version>
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<sonar.skip>true</sonar.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.open-metadata</groupId>
<artifactId>openmetadata-spec</artifactId>
<version>${project.version}</version>
</dependency>
<!-- FEIGN DEPENDENCY-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
<version>${feign-version}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-jackson</artifactId>
<version>${feign-version}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-slf4j</artifactId>
<version>${feign-version}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
<version>${feign-version}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign.form</groupId>
<artifactId>feign-form</artifactId>
<version>3.8.0</version>
</dependency>
<!-- FEIGN DEPENDENCY END -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${jackson-databind-nullable-version}</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${jakarta-annotation-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
<version>${swagger-parser-version}</version>
</dependency>
<dependency>
<groupId>com.github.scribejava</groupId>
<artifactId>scribejava-apis</artifactId>
<version>${scribejava-apis-version}</version>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>1.29.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
<version>1.17.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- TEST -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<!--avoid security issue https://security.snyk.io/vuln/SNYK-JAVA-ORGMOZILLA-1314295-->
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>1.7.15.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${org.junit.jupiter.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-javadoc-plugin.version}</version>
<configuration>
<doclint>none</doclint>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<ignoredDependencies>
<ignoredDependency>org.projectlombok:lombok</ignoredDependency>
</ignoredDependencies>
</configuration>
</execution>
</executions>
</plugin>
<!--Reformat Code to comply with Google Java Style -->
<plugin>
<groupId>com.theoryinpractise</groupId>
<artifactId>googleformatter-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-source-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<outputDirectory>${project.build.directory}/classes/catalog</outputDirectory>
<outputName>VERSION</outputName>
</configuration>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>create-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.13.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/../../openmetadata-service/target/classes/assets/swagger.yaml</inputSpec>
<generatorName>java</generatorName>
<library>feign</library>
<apiPackage>org.openmetadata.client.api</apiPackage>
<modelPackage>org.openmetadata.client.model</modelPackage>
<output>
${project.build.directory}/generated-sources/swagger
</output>
<skipOperationExample>true</skipOperationExample>
<skipValidateSpec>true</skipValidateSpec>
<templateDirectory>${project.basedir}/src/main/openapi-templates</templateDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,550 @@
package org.openmetadata.client.api;
import feign.Headers;
import feign.Param;
import feign.QueryMap;
import feign.RequestLine;
import feign.Response;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.openmetadata.client.ApiClient;
import org.openmetadata.client.EncodingUtils;
@Deprecated(since = "1.12.0", forRemoval = true)
public interface ElasticSearchApi extends ApiClient.Api {
/**
* Get Aggregated Fields Get Aggregated Fields from Entities.
*
* @param index (optional, default to table_search_index)
* @param field Field in an entity. (optional)
* @param size Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* @param deleted (optional, default to false)
* @return Suggest
*/
@RequestLine("GET /v1/search/aggregate?index={index}&field={field}&size={size}&deleted={deleted}")
@Headers({
"Accept: application/json",
})
Response getAggregateFields(
@Param("index") String index,
@Param("field") String field,
@Param("size") Integer size,
@Param("deleted") String deleted);
/**
* Get Aggregated Fields Similar to <code>getAggregateFields</code> but it also returns the http response headers .
* Get Aggregated Fields from Entities.
*
* @param index (optional, default to table_search_index)
* @param field Field in an entity. (optional)
* @param size Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* @param deleted (optional, default to false)
* @return A ApiResponse that wraps the response boyd and the http headers.
*/
@RequestLine("GET /v1/search/aggregate?index={index}&field={field}&size={size}&deleted={deleted}")
@Headers({
"Accept: application/json",
})
Response getAggregateFieldsWithHttpInfo(
@Param("index") String index,
@Param("field") String field,
@Param("size") Integer size,
@Param("deleted") String deleted);
/**
* Get Aggregated Fields Get Aggregated Fields from Entities. Note, this is equivalent to the other <code>
* getAggregateFields</code> method, but with the query parameters collected into a single Map parameter. This is
* convenient for services with optional query parameters, especially when used with the {@link
* GetAggregateFieldsQueryParams} class that allows for building up this map in a fluent style.
*
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:
* <ul>
* <li>index - (optional, default to table_search_index)
* <li>field - Field in an entity. (optional)
* <li>size - Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* <li>deleted - (optional, default to false)
* </ul>
*
* @return Suggest
*/
@RequestLine("GET /v1/search/aggregate?index={index}&field={field}&size={size}&deleted={deleted}")
@Headers({
"Accept: application/json",
})
Response getAggregateFields(@QueryMap(encoded = true) Map<String, Object> queryParams);
/**
* Get Aggregated Fields Get Aggregated Fields from Entities. Note, this is equivalent to the other <code>
* getAggregateFields</code> that receives the query parameters as a map, but this one also exposes the Http response
* headers
*
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:
* <ul>
* <li>index - (optional, default to table_search_index)
* <li>field - Field in an entity. (optional)
* <li>size - Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* <li>deleted - (optional, default to false)
* </ul>
*
* @return Suggest
*/
@RequestLine("GET /v1/search/aggregate?index={index}&field={field}&size={size}&deleted={deleted}")
@Headers({
"Accept: application/json",
})
Response getAggregateFieldsWithHttpInfo(
@QueryMap(encoded = true) Map<String, Object> queryParams);
/**
* A convenience class for generating query parameters for the <code>getAggregateFields</code> method in a fluent
* style.
*/
class GetAggregateFieldsQueryParams extends HashMap<String, Object> {
public GetAggregateFieldsQueryParams index(final String value) {
put("index", EncodingUtils.encode(value));
return this;
}
public GetAggregateFieldsQueryParams field(final String value) {
put("field", EncodingUtils.encode(value));
return this;
}
public GetAggregateFieldsQueryParams size(final Integer value) {
put("size", EncodingUtils.encode(value));
return this;
}
public GetAggregateFieldsQueryParams deleted(final String value) {
put("deleted", EncodingUtils.encode(value));
return this;
}
}
/**
* Suggest Entities Get suggested entities used for auto-completion.
*
* @param q Suggest API can be used to auto-fill the entities name while use is typing search text <br>
* 1. To get suggest results pass q=us or q=user etc.. <br>
* 2. Do not add any wild-cards such as * like in search api <br>
* 3. suggest api is a prefix suggestion <br>
* (required)
* @param index (optional, default to table_search_index)
* @param field Field in object containing valid suggestions. Defaults to `suggest`. All indices has a `suggest`
* field, only some indices have other `suggest_*` fields. (optional, default to suggest)
* @param size Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* @param fetchSource Get document body for each hit (optional, default to true)
* @param includeSourceFields Get only selected fields of the document body for each hit. Empty value will return all
* fields (optional)
* @param deleted (optional, default to false)
* @return Suggest
*/
@RequestLine(
"GET /v1/search/suggest?q={q}&index={index}&field={field}&size={size}&fetch_source={fetchSource}&include_source_fields={includeSourceFields}&deleted={deleted}")
@Headers({
"Accept: application/json",
})
Response getSuggestedEntities(
@Param("q") String q,
@Param("index") String index,
@Param("field") String field,
@Param("size") Integer size,
@Param("fetchSource") Boolean fetchSource,
@Param("includeSourceFields") List<String> includeSourceFields,
@Param("deleted") String deleted);
/**
* Suggest Entities Similar to <code>getSuggestedEntities</code> but it also returns the http response headers . Get
* suggested entities used for auto-completion.
*
* @param q Suggest API can be used to auto-fill the entities name while use is typing search text <br>
* 1. To get suggest results pass q=us or q=user etc.. <br>
* 2. Do not add any wild-cards such as * like in search api <br>
* 3. suggest api is a prefix suggestion <br>
* (required)
* @param index (optional, default to table_search_index)
* @param field Field in object containing valid suggestions. Defaults to `suggest`. All indices has a `suggest`
* field, only some indices have other `suggest_*` fields. (optional, default to suggest)
* @param size Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* @param fetchSource Get document body for each hit (optional, default to true)
* @param includeSourceFields Get only selected fields of the document body for each hit. Empty value will return all
* fields (optional)
* @param deleted (optional, default to false)
* @return A ApiResponse that wraps the response boyd and the http headers.
*/
@RequestLine(
"GET /v1/search/suggest?q={q}&index={index}&field={field}&size={size}&fetch_source={fetchSource}&include_source_fields={includeSourceFields}&deleted={deleted}")
@Headers({
"Accept: application/json",
})
Response getSuggestedEntitiesWithHttpInfo(
@Param("q") String q,
@Param("index") String index,
@Param("field") String field,
@Param("size") Integer size,
@Param("fetchSource") Boolean fetchSource,
@Param("includeSourceFields") List<String> includeSourceFields,
@Param("deleted") String deleted);
/**
* Suggest Entities Get suggested entities used for auto-completion. Note, this is equivalent to the other <code>
* getSuggestedEntities</code> method, but with the query parameters collected into a single Map parameter. This is
* convenient for services with optional query parameters, especially when used with the {@link
* GetSuggestedEntitiesQueryParams} class that allows for building up this map in a fluent style.
*
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:
* <ul>
* <li>q - Suggest API can be used to auto-fill the entities name while use is typing search text <br>
* 1. To get suggest results pass q=us or q=user etc.. <br>
* 2. Do not add any wild-cards such as * like in search api <br>
* 3. suggest api is a prefix suggestion <br>
* (required)
* <li>index - (optional, default to table_search_index)
* <li>field - Field in object containing valid suggestions. Defaults to `suggest`. All indices has a `suggest`
* field, only some indices have other `suggest_*` fields. (optional, default to suggest)
* <li>size - Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* <li>fetchSource - Get document body for each hit (optional, default to true)
* <li>includeSourceFields - Get only selected fields of the document body for each hit. Empty value will return
* all fields (optional)
* <li>deleted - (optional, default to false)
* </ul>
*
* @return Suggest
*/
@RequestLine(
"GET /v1/search/suggest?q={q}&index={index}&field={field}&size={size}&fetch_source={fetchSource}&include_source_fields={includeSourceFields}&deleted={deleted}")
@Headers({
"Accept: application/json",
})
Response getSuggestedEntities(@QueryMap(encoded = true) Map<String, Object> queryParams);
/**
* Suggest Entities Get suggested entities used for auto-completion. Note, this is equivalent to the other <code>
* getSuggestedEntities</code> that receives the query parameters as a map, but this one also exposes the Http
* response headers
*
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:
* <ul>
* <li>q - Suggest API can be used to auto-fill the entities name while use is typing search text <br>
* 1. To get suggest results pass q=us or q=user etc.. <br>
* 2. Do not add any wild-cards such as * like in search api <br>
* 3. suggest api is a prefix suggestion <br>
* (required)
* <li>index - (optional, default to table_search_index)
* <li>field - Field in object containing valid suggestions. Defaults to `suggest`. All indices has a `suggest`
* field, only some indices have other `suggest_*` fields. (optional, default to suggest)
* <li>size - Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* <li>fetchSource - Get document body for each hit (optional, default to true)
* <li>includeSourceFields - Get only selected fields of the document body for each hit. Empty value will return
* all fields (optional)
* <li>deleted - (optional, default to false)
* </ul>
*
* @return Suggest
*/
@RequestLine(
"GET /v1/search/suggest?q={q}&index={index}&field={field}&size={size}&fetch_source={fetchSource}&include_source_fields={includeSourceFields}&deleted={deleted}")
@Headers({
"Accept: application/json",
})
Response getSuggestedEntitiesWithHttpInfo(
@QueryMap(encoded = true) Map<String, Object> queryParams);
/**
* A convenience class for generating query parameters for the <code>getSuggestedEntities</code> method in a fluent
* style.
*/
class GetSuggestedEntitiesQueryParams extends HashMap<String, Object> {
public GetSuggestedEntitiesQueryParams q(final String value) {
put("q", EncodingUtils.encode(value));
return this;
}
public GetSuggestedEntitiesQueryParams index(final String value) {
put("index", EncodingUtils.encode(value));
return this;
}
public GetSuggestedEntitiesQueryParams field(final String value) {
put("field", EncodingUtils.encode(value));
return this;
}
public GetSuggestedEntitiesQueryParams size(final Integer value) {
put("size", EncodingUtils.encode(value));
return this;
}
public GetSuggestedEntitiesQueryParams fetchSource(final Boolean value) {
put("fetch_source", EncodingUtils.encode(value));
return this;
}
public GetSuggestedEntitiesQueryParams includeSourceFields(final List<String> value) {
put("include_source_fields", EncodingUtils.encodeCollection(value, "multi"));
return this;
}
public GetSuggestedEntitiesQueryParams deleted(final String value) {
put("deleted", EncodingUtils.encode(value));
return this;
}
}
/**
* Search entities Search entities using query test. Use query params `from` and `size` for pagination. Use
* `sort_field` to sort the results in `sort_order`.
*
* @param q Search Query Text, Pass *text* for substring match; Pass without wildcards for exact match. <br>
* 1. For listing all tables or topics pass q=* <br>
* 2. For search tables or topics pass q=*search_term* <br>
* 3. For searching field names such as search by column_name pass q=column_names:address <br>
* 4. For searching by tag names pass q=tags:user.email <br>
* 5. When user selects a filter pass q=query_text AND tags:user.email AND platform:MYSQL <br>
* 6. Search with multiple values of same filter q=tags:user.email AND tags:user.address <br>
* logic operators such as AND and OR must be in uppercase (required)
* @param index ElasticSearch Index name, defaults to table_search_index (optional, default to table_search_index)
* @param deleted Filter documents by deleted param. By default deleted is false (optional, default to false)
* @param from From field to paginate the results, defaults to 0 (optional, default to 0)
* @param size Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* @param sortField Sort the search results by field, available fields to sort weekly_stats , daily_stats,
* monthly_stats, last_updated_timestamp (optional, default to _score)
* @param sortOrder Sort order asc for ascending or desc for descending, defaults to desc (optional, default to desc)
* @param trackTotalHits Track Total Hits (optional, default to false)
* @param queryFilter Elasticsearch query that will be combined with the query_string query generator from the `query`
* argument (optional)
* @param postFilter Elasticsearch query that will be used as a post_filter (optional)
* @param fetchSource Get document body for each hit (optional, default to true)
* @param includeSourceFields Get only selected fields of the document body for each hit. Empty value will return all
* fields (optional)
* @return SearchResponse
*/
@RequestLine(
"GET /v1/search/query?q={q}&index={index}&deleted={deleted}&from={from}&size={size}&sort_field={sortField}&sort_order={sortOrder}&track_total_hits={trackTotalHits}&query_filter={queryFilter}&post_filter={postFilter}&fetch_source={fetchSource}&include_source_fields={includeSourceFields}")
@Headers({
"Accept: application/json",
})
Response searchEntitiesWithQuery(
@Param("q") String q,
@Param("index") String index,
@Param("deleted") Boolean deleted,
@Param("from") Integer from,
@Param("size") Integer size,
@Param("sortField") String sortField,
@Param("sortOrder") String sortOrder,
@Param("trackTotalHits") Boolean trackTotalHits,
@Param("queryFilter") String queryFilter,
@Param("postFilter") String postFilter,
@Param("fetchSource") Boolean fetchSource,
@Param("includeSourceFields") List<String> includeSourceFields);
/**
* Search entities Similar to <code>searchEntitiesWithQuery</code> but it also returns the http response headers .
* Search entities using query test. Use query params `from` and `size` for pagination. Use `sort_field` to sort the
* results in `sort_order`.
*
* @param q Search Query Text, Pass *text* for substring match; Pass without wildcards for exact match. <br>
* 1. For listing all tables or topics pass q=* <br>
* 2. For search tables or topics pass q=*search_term* <br>
* 3. For searching field names such as search by column_name pass q=column_names:address <br>
* 4. For searching by tag names pass q=tags:user.email <br>
* 5. When user selects a filter pass q=query_text AND tags:user.email AND platform:MYSQL <br>
* 6. Search with multiple values of same filter q=tags:user.email AND tags:user.address <br>
* logic operators such as AND and OR must be in uppercase (required)
* @param index ElasticSearch Index name, defaults to table_search_index (optional, default to table_search_index)
* @param deleted Filter documents by deleted param. By default deleted is false (optional, default to false)
* @param from From field to paginate the results, defaults to 0 (optional, default to 0)
* @param size Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* @param sortField Sort the search results by field, available fields to sort weekly_stats , daily_stats,
* monthly_stats, last_updated_timestamp (optional, default to _score)
* @param sortOrder Sort order asc for ascending or desc for descending, defaults to desc (optional, default to desc)
* @param trackTotalHits Track Total Hits (optional, default to false)
* @param queryFilter Elasticsearch query that will be combined with the query_string query generator from the `query`
* argument (optional)
* @param postFilter Elasticsearch query that will be used as a post_filter (optional)
* @param fetchSource Get document body for each hit (optional, default to true)
* @param includeSourceFields Get only selected fields of the document body for each hit. Empty value will return all
* fields (optional)
* @return A ApiResponse that wraps the response boyd and the http headers.
*/
@RequestLine(
"GET /v1/search/query?q={q}&index={index}&deleted={deleted}&from={from}&size={size}&sort_field={sortField}&sort_order={sortOrder}&track_total_hits={trackTotalHits}&query_filter={queryFilter}&post_filter={postFilter}&fetch_source={fetchSource}&include_source_fields={includeSourceFields}")
@Headers({
"Accept: application/json",
})
Response searchEntitiesWithQueryWithHttpInfo(
@Param("q") String q,
@Param("index") String index,
@Param("deleted") Boolean deleted,
@Param("from") Integer from,
@Param("size") Integer size,
@Param("sortField") String sortField,
@Param("sortOrder") String sortOrder,
@Param("trackTotalHits") Boolean trackTotalHits,
@Param("queryFilter") String queryFilter,
@Param("postFilter") String postFilter,
@Param("fetchSource") Boolean fetchSource,
@Param("includeSourceFields") List<String> includeSourceFields);
/**
* Search entities Search entities using query test. Use query params `from` and `size` for pagination. Use
* `sort_field` to sort the results in `sort_order`. Note, this is equivalent to the other <code>
* searchEntitiesWithQuery</code> method, but with the query parameters collected into a single Map parameter. This is
* convenient for services with optional query parameters, especially when used with the {@link
* SearchEntitiesWithQueryQueryParams} class that allows for building up this map in a fluent style.
*
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:
* <ul>
* <li>q - Search Query Text, Pass *text* for substring match; Pass without wildcards for exact match. <br>
* 1. For listing all tables or topics pass q=* <br>
* 2. For search tables or topics pass q=*search_term* <br>
* 3. For searching field names such as search by column_name pass q=column_names:address <br>
* 4. For searching by tag names pass q=tags:user.email <br>
* 5. When user selects a filter pass q=query_text AND tags:user.email AND platform:MYSQL <br>
* 6. Search with multiple values of same filter q=tags:user.email AND tags:user.address <br>
* logic operators such as AND and OR must be in uppercase (required)
* <li>index - ElasticSearch Index name, defaults to table_search_index (optional, default to
* table_search_index)
* <li>deleted - Filter documents by deleted param. By default deleted is false (optional, default to false)
* <li>from - From field to paginate the results, defaults to 0 (optional, default to 0)
* <li>size - Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* <li>sortField - Sort the search results by field, available fields to sort weekly_stats , daily_stats,
* monthly_stats, last_updated_timestamp (optional, default to _score)
* <li>sortOrder - Sort order asc for ascending or desc for descending, defaults to desc (optional, default to
* desc)
* <li>trackTotalHits - Track Total Hits (optional, default to false)
* <li>queryFilter - Elasticsearch query that will be combined with the query_string query generator from the
* `query` argument (optional)
* <li>postFilter - Elasticsearch query that will be used as a post_filter (optional)
* <li>fetchSource - Get document body for each hit (optional, default to true)
* <li>includeSourceFields - Get only selected fields of the document body for each hit. Empty value will return
* all fields (optional)
* </ul>
*
* @return SearchResponse
*/
@RequestLine(
"GET /v1/search/query?q={q}&index={index}&deleted={deleted}&from={from}&size={size}&sort_field={sortField}&sort_order={sortOrder}&track_total_hits={trackTotalHits}&query_filter={queryFilter}&post_filter={postFilter}&fetch_source={fetchSource}&include_source_fields={includeSourceFields}")
@Headers({
"Accept: application/json",
})
Response searchEntitiesWithQuery(@QueryMap(encoded = true) Map<String, Object> queryParams);
/**
* Search entities Search entities using query test. Use query params `from` and `size` for pagination. Use
* `sort_field` to sort the results in `sort_order`. Note, this is equivalent to the other <code>
* searchEntitiesWithQuery</code> that receives the query parameters as a map, but this one also exposes the Http
* response headers
*
* @param queryParams Map of query parameters as name-value pairs
* <p>The following elements may be specified in the query map:
* <ul>
* <li>q - Search Query Text, Pass *text* for substring match; Pass without wildcards for exact match. <br>
* 1. For listing all tables or topics pass q=* <br>
* 2. For search tables or topics pass q=*search_term* <br>
* 3. For searching field names such as search by column_name pass q=column_names:address <br>
* 4. For searching by tag names pass q=tags:user.email <br>
* 5. When user selects a filter pass q=query_text AND tags:user.email AND platform:MYSQL <br>
* 6. Search with multiple values of same filter q=tags:user.email AND tags:user.address <br>
* logic operators such as AND and OR must be in uppercase (required)
* <li>index - ElasticSearch Index name, defaults to table_search_index (optional, default to
* table_search_index)
* <li>deleted - Filter documents by deleted param. By default deleted is false (optional, default to false)
* <li>from - From field to paginate the results, defaults to 0 (optional, default to 0)
* <li>size - Size field to limit the no.of results returned, defaults to 10 (optional, default to 10)
* <li>sortField - Sort the search results by field, available fields to sort weekly_stats , daily_stats,
* monthly_stats, last_updated_timestamp (optional, default to _score)
* <li>sortOrder - Sort order asc for ascending or desc for descending, defaults to desc (optional, default to
* desc)
* <li>trackTotalHits - Track Total Hits (optional, default to false)
* <li>queryFilter - Elasticsearch query that will be combined with the query_string query generator from the
* `query` argument (optional)
* <li>postFilter - Elasticsearch query that will be used as a post_filter (optional)
* <li>fetchSource - Get document body for each hit (optional, default to true)
* <li>includeSourceFields - Get only selected fields of the document body for each hit. Empty value will return
* all fields (optional)
* </ul>
*
* @return SearchResponse
*/
@RequestLine(
"GET /v1/search/query?q={q}&index={index}&deleted={deleted}&from={from}&size={size}&sort_field={sortField}&sort_order={sortOrder}&track_total_hits={trackTotalHits}&query_filter={queryFilter}&post_filter={postFilter}&fetch_source={fetchSource}&include_source_fields={includeSourceFields}")
@Headers({
"Accept: application/json",
})
Response searchEntitiesWithQueryWithHttpInfo(
@QueryMap(encoded = true) Map<String, Object> queryParams);
/**
* A convenience class for generating query parameters for the <code>searchEntitiesWithQuery</code> method in a fluent
* style.
*/
class SearchEntitiesWithQueryQueryParams extends HashMap<String, Object> {
public SearchEntitiesWithQueryQueryParams q(final String value) {
put("q", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams index(final String value) {
put("index", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams deleted(final Boolean value) {
put("deleted", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams from(final Integer value) {
put("from", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams size(final Integer value) {
put("size", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams sortField(final String value) {
put("sort_field", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams sortOrder(final String value) {
put("sort_order", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams trackTotalHits(final Boolean value) {
put("track_total_hits", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams queryFilter(final String value) {
put("query_filter", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams postFilter(final String value) {
put("post_filter", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams fetchSource(final Boolean value) {
put("fetch_source", EncodingUtils.encode(value));
return this;
}
public SearchEntitiesWithQueryQueryParams includeSourceFields(final List<String> value) {
put("include_source_fields", EncodingUtils.encodeCollection(value, "multi"));
return this;
}
}
}
@@ -0,0 +1,124 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openmetadata.client.gateway;
import com.fasterxml.jackson.annotation.JsonInclude;
import feign.Feign;
import feign.RequestTemplate;
import feign.form.FormEncoder;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import feign.okhttp.OkHttpClient;
import feign.slf4j.Slf4jLogger;
import java.util.Map;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.openmetadata.client.ApiClient;
import org.openmetadata.client.api.SystemApi;
import org.openmetadata.client.security.factory.AuthenticationProviderFactory;
import org.openmetadata.schema.api.OpenMetadataServerVersion;
import org.openmetadata.schema.services.connections.metadata.OpenMetadataConnection;
import org.openmetadata.schema.utils.VersionUtils;
@Slf4j
@Deprecated(since = "1.12.0", forRemoval = true)
public class OpenMetadata {
private static final OpenMetadataServerVersion OPENMETADATA_VERSION_CLIENT;
static {
OPENMETADATA_VERSION_CLIENT = VersionUtils.getOpenMetadataServerVersion("/catalog/VERSION");
}
private ApiClient apiClient;
private static final String REQUEST_INTERCEPTOR_KEY = "custom";
public OpenMetadata(OpenMetadataConnection config) {
initClient(config);
validateVersion();
}
public OpenMetadata(OpenMetadataConnection config, boolean validateVersion) {
initClient(config);
if (validateVersion) validateVersion();
}
public void initClient(OpenMetadataConnection config) {
apiClient = new ApiClient();
Feign.Builder builder =
Feign.builder()
.encoder(new FormEncoder(new JacksonEncoder(apiClient.getObjectMapper())))
.decoder(new JacksonDecoder(apiClient.getObjectMapper()))
.logger(new Slf4jLogger())
.client(new OkHttpClient());
initClient(config, builder);
}
public void initClient(OpenMetadataConnection config, Feign.Builder builder) {
if (Objects.isNull(apiClient)) {
apiClient = new ApiClient();
}
if (config.getExtraHeaders() != null
&& config.getExtraHeaders().getAdditionalProperties() != null
&& !config.getExtraHeaders().getAdditionalProperties().isEmpty()) {
builder.requestInterceptor(
requestTemplate ->
applyExtraHeaders(
requestTemplate, config.getExtraHeaders().getAdditionalProperties()));
}
apiClient.setFeignBuilder(builder);
AuthenticationProviderFactory factory = new AuthenticationProviderFactory();
apiClient.addAuthorization("oauth", factory.getAuthProvider(config));
String basePath = config.getHostPort() + "/";
apiClient.setBasePath(basePath);
apiClient.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
public <T extends ApiClient.Api> T buildClient(Class<T> clientClass) {
return apiClient.buildClient(clientClass);
}
public void validateVersion() {
String[] clientVersion = getClientVersion();
String[] serverVersion = getServerVersion();
// MAJOR MINOR REVISION
if (serverVersion[0].equals(clientVersion[0])
&& serverVersion[1].equals(clientVersion[1])
&& serverVersion[2].equals(clientVersion[2])) {
LOG.debug("OpenMetaData Client Initialized successfully.");
} else {
LOG.error(
"OpenMetaData Client Failed to be Initialized successfully. Version mismatch between CLient and Server issue");
}
}
public String[] getServerVersion() {
SystemApi api = apiClient.buildClient(SystemApi.class);
org.openmetadata.client.model.OpenMetadataServerVersion serverVersion = api.getCatalogVersion();
return VersionUtils.getVersionFromString(serverVersion.getVersion());
}
public String[] getClientVersion() {
return VersionUtils.getVersionFromString(OPENMETADATA_VERSION_CLIENT.getVersion());
}
private void applyExtraHeaders(RequestTemplate template, Map<String, String> extraHeaders) {
for (Map.Entry<String, String> entry : extraHeaders.entrySet()) {
String headerValue = entry.getValue() != null ? entry.getValue() : "";
template.header(entry.getKey(), headerValue);
LOG.debug("Applied extra header: {} = {}", entry.getKey(), headerValue);
}
}
}
@@ -0,0 +1,146 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openmetadata.client.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.HashMap;
import java.util.Map;
@Deprecated(since = "1.12.0", forRemoval = true)
public class AccessTokenResponse {
@JsonProperty("token_type")
private String tokenType = null;
@JsonProperty("expires_in")
private Long expiresIn = null;
@JsonProperty("access_token")
private String accessToken = null;
@JsonProperty("scope")
private String scope = null;
/**
* Get TokenType
*
* @return TokenType
*/
@Schema(description = "")
public String getTokenType() {
return tokenType;
}
public void setTokenType(String description) {
this.tokenType = description;
}
public AccessTokenResponse withTokenType(String displayName) {
this.tokenType = displayName;
return this;
}
/**
* Get ExpiresIn
*
* @return ExpiresIn
*/
@Schema()
public Long getExpiresIn() {
return expiresIn;
}
public void setExpiresIn(Long iExpiresIn) {
this.expiresIn = iExpiresIn;
}
public AccessTokenResponse withExpiresIn(Long iExpiresIn) {
this.expiresIn = iExpiresIn;
return this;
}
/**
* Get AccessToken
*
* @return AccessToken
*/
@Schema()
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String iAccessToken) {
this.accessToken = iAccessToken;
}
public AccessTokenResponse withAccessToken(String iAccessToken) {
this.accessToken = iAccessToken;
return this;
}
/**
* Get Scope
*
* @return Scope
*/
@Schema()
public String getScope() {
return scope;
}
public void setScope(String iScopes) {
this.scope = iScopes;
}
public AccessTokenResponse withScope(String iScopes) {
this.scope = iScopes;
return this;
}
public enum GrantType {
AUTHORIZATION_CODE("authorization_code"),
CLIENT_CREDENTIALS("client_credentials"),
IMPLICIT("implicit");
private final String value;
private static final Map<String, AccessTokenResponse.GrantType> CONSTANTS = new HashMap<>();
static {
for (AccessTokenResponse.GrantType c : values()) {
CONSTANTS.put(c.value, c);
}
}
GrantType(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
public String value() {
return this.value;
}
public static AccessTokenResponse.GrantType fromValue(String value) {
AccessTokenResponse.GrantType constant = CONSTANTS.get(value);
if (constant == null) {
throw new IllegalArgumentException(value);
} else {
return constant;
}
}
}
}
@@ -0,0 +1,65 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openmetadata.client.model;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
@Deprecated(since = "1.12.0", forRemoval = true)
public class OktaSSOConfig {
/** Okta Client ID for the service application. (Required) */
@Getter @Setter private String clientId;
/** Okta Client Secret for the API service application. (Required) */
@Getter @Setter private String clientSecret;
/** Okta Authorization Server Url. (Required) */
@Getter private String authorizationServerURL;
/** Okta client scopes. */
@Getter @Setter private List<String> scopes = new ArrayList<>();
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(OktaSSOConfig.class.getName())
.append('@')
.append(Integer.toHexString(System.identityHashCode(this)))
.append('[');
sb.append("clientId");
sb.append('=');
sb.append(((this.clientId == null) ? "<null>" : this.clientId));
sb.append("clientSecret");
sb.append('=');
sb.append(((this.clientSecret == null) ? "<null>" : this.clientSecret));
sb.append(',');
sb.append("authorizationServerURL");
sb.append('=');
sb.append(((this.authorizationServerURL == null) ? "<null>" : this.authorizationServerURL));
sb.append(',');
sb.append(',');
sb.append("scopes");
sb.append('=');
sb.append(((this.scopes == null) ? "<null>" : this.scopes));
sb.append(',');
if (sb.charAt((sb.length() - 1)) == ',') {
sb.setCharAt((sb.length() - 1), ']');
} else {
sb.append(']');
}
return sb.toString();
}
}
@@ -0,0 +1,79 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openmetadata.client.security;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.openmetadata.client.security.interfaces.AuthenticationProvider;
import org.openmetadata.schema.security.client.OpenMetadataJWTClientConfig;
import org.openmetadata.schema.services.connections.metadata.AuthProvider;
import org.openmetadata.schema.services.connections.metadata.OpenMetadataConnection;
@Slf4j
@Deprecated(since = "1.12.0", forRemoval = true)
public class OpenMetadataAuthenticationProvider implements AuthenticationProvider {
private final OpenMetadataJWTClientConfig securityConfig;
private String generatedAuthToken;
private Long expirationTimeMillis;
public OpenMetadataAuthenticationProvider(OpenMetadataConnection iConfig) {
if (!iConfig.getAuthProvider().equals(AuthProvider.OPENMETADATA)) {
LOG.error("Required type to invoke is OpenMetadata for OpenMetadataAuthentication Provider");
throw new RuntimeException(
"Required type to invoke is OpenMetadata for OpenMetadataAuthentication Provider");
}
securityConfig = iConfig.getSecurityConfig();
if (securityConfig == null) {
LOG.error("Security Config is missing, it is required");
throw new RuntimeException("Security Config is missing, it is required");
}
generatedAuthToken = "";
}
@Override
public AuthenticationProvider create(OpenMetadataConnection iConfig) {
return new OpenMetadataAuthenticationProvider(iConfig);
}
@Override
public String authToken() {
generatedAuthToken = securityConfig.getJwtToken();
return generatedAuthToken;
}
@Override
public String getAccessToken() {
return generatedAuthToken;
}
@Override
public void apply(RequestTemplate requestTemplate) {
String url = requestTemplate.url();
if (url.endsWith("/system/version") || url.contains("/system/version?")) {
return;
}
if (requestTemplate.headers().containsKey("Authorization")) {
return;
}
// If first time, get the token
if (expirationTimeMillis == null || System.currentTimeMillis() >= expirationTimeMillis) {
this.authToken();
}
if (getAccessToken() != null) {
requestTemplate.header("Authorization", "Bearer " + getAccessToken());
}
}
}
@@ -0,0 +1,30 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openmetadata.client.security.factory;
import java.util.Objects;
import org.openmetadata.client.security.OpenMetadataAuthenticationProvider;
import org.openmetadata.client.security.interfaces.AuthenticationProvider;
import org.openmetadata.schema.services.connections.metadata.AuthProvider;
import org.openmetadata.schema.services.connections.metadata.OpenMetadataConnection;
@Deprecated(since = "1.12.0", forRemoval = true)
public class AuthenticationProviderFactory {
public AuthenticationProvider getAuthProvider(OpenMetadataConnection serverConfig) {
if (Objects.requireNonNull(serverConfig.getAuthProvider()) == AuthProvider.OPENMETADATA) {
return new OpenMetadataAuthenticationProvider(serverConfig);
}
return null;
}
}
@@ -0,0 +1,26 @@
/*
* Copyright 2021 Collate
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openmetadata.client.security.interfaces;
import feign.RequestInterceptor;
import org.openmetadata.schema.services.connections.metadata.OpenMetadataConnection;
@Deprecated(since = "1.12.0", forRemoval = true)
public interface AuthenticationProvider extends RequestInterceptor {
AuthenticationProvider create(OpenMetadataConnection iConfig);
String authToken();
String getAccessToken();
}
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<version>{{artifactVersion}}</version>
<packaging>jar</packaging>
</project>
@@ -0,0 +1,82 @@
package org.openmetadata.client.security;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import feign.RequestTemplate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openmetadata.schema.security.client.OpenMetadataJWTClientConfig;
import org.openmetadata.schema.services.connections.metadata.AuthProvider;
import org.openmetadata.schema.services.connections.metadata.OpenMetadataConnection;
public class OpenMetadataAuthenticationProviderTest {
private OpenMetadataAuthenticationProvider provider;
@BeforeEach
public void setUp() {
OpenMetadataConnection connection =
new OpenMetadataConnection()
.withAuthProvider(AuthProvider.OPENMETADATA)
.withHostPort("http://localhost:8585/api")
.withSecurityConfig(new OpenMetadataJWTClientConfig().withJwtToken("test-token"));
provider = new OpenMetadataAuthenticationProvider(connection);
}
@Test
public void testAuthenticationAddedForEntityNamesContainingVersion() {
RequestTemplate template = new RequestTemplate();
template.uri("/v1/teams/name/data-conversion-service");
provider.apply(template);
assertTrue(
template.headers().containsKey("Authorization"),
"Authorization header should be added for entities with 'conversion' in name");
}
@Test
public void testAuthenticationAddedForEntityNamesWithVersionSubstring() {
RequestTemplate template = new RequestTemplate();
template.uri("/v1/topics/name/dataset-version-update-events");
provider.apply(template);
assertTrue(
template.headers().containsKey("Authorization"),
"Authorization header should be added for entities with 'version' in name");
}
@Test
public void testAuthenticationSkippedForVersionEndpoint() {
RequestTemplate template = new RequestTemplate();
template.uri("/v1/system/version");
provider.apply(template);
assertFalse(
template.headers().containsKey("Authorization"),
"Authorization header should NOT be added for /system/version endpoint");
}
@Test
public void testAuthenticationSkippedForVersionEndpointWithQueryParams() {
RequestTemplate template = new RequestTemplate();
template.uri("/v1/system/version?param=value");
provider.apply(template);
assertFalse(
template.headers().containsKey("Authorization"),
"Authorization header should NOT be added for /system/version endpoint with query params");
}
@Test
public void testAuthenticationAddedForRegularEndpoints() {
RequestTemplate template = new RequestTemplate();
template.uri("/v1/teams/name/my-team");
provider.apply(template);
assertTrue(
template.headers().containsKey("Authorization"),
"Authorization header should be added for regular endpoints");
}
}